<template>
    <div v-cloak>
        <div class="head-tools">
            <i></i>
            <span class="name">{{base.markName}}</span>
            <div class="select-box">
                <span style="margin:2px 8px 0 0;" @click="robot()"><img src="/static/images/客服.svg" alt=""></span>
                <span class="keyboard" @mouseover="promptShow.shortcuts = true" @mouseout="promptShow.shortcuts = false">
                    快捷键
                    <b>|</b>
                    <div class="showBox" style="color: rgb(0, 0, 0);overflow: scroll;" v-show="promptShow.shortcuts">
                        <div class="table">
                            <table width="100%">
                                <thead>
                                    <tr>
                                        <th>功能说明</th>
                                        <th>热键</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>多边形</td>
                                        <td>Z</td>
                                    </tr>
                                    <tr>
                                        <td>矩形</td>
                                        <td>A</td>
                                    </tr>
                                    <tr>
                                        <td>快捷隐藏标记框</td>
                                        <td>Tab</td>
                                    </tr>
                                    <tr>
                                        <td>取消绘图</td>
                                        <td>Esc</td>
                                    </tr>
                                    <tr>
                                        <td>快速编辑</td>
                                        <td>双击图形 / 选中 + Enter</td>
                                    </tr>
                                    <tr>
                                        <td>拖拽图片</td>
                                        <td>Space + 左键</td>
                                    </tr>
                                    <tr>
                                        <td>撤销多边形绘制点</td>
                                        <td>ctrl + Z</td>
                                    </tr>
                                    <tr>
                                        <td>删除</td>
                                        <td>右键</td>
                                    </tr>
                                    <tr>
                                        <td>上一张</td>
                                        <td>Q</td>
                                    </tr>
                                    <tr>
                                        <td>下一张</td>
                                        <td>E</td>
                                    </tr>
                                    <tr>
                                        <td>筛选</td>
                                        <td>S</td>
                                    </tr>
                                    <tr>
                                        <td>放大</td>
                                        <td>滚轮上滑</td>
                                    </tr>
                                    <tr>
                                        <td>缩小</td>
                                        <td>滚轮下滑</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </span>
                <span class="stand" @mouseover="promptShow.standard = true" @mouseout="promptShow.standard = false">
                    标注规范
                    <b>|</b>
                    <div class="showBox" v-show="promptShow.standard">
                        <ul class="listheight">
                            <p v-html="base.markStandard"></p>
                        </ul>
                    </div>
                </span>
                <span class="history" @click="showHistory">历史</span>
                <b class="states">
                    <b class="operations" v-show="!history.showVersionInfo">
                        <a class="save" @click="save">保存</a>
                        <a class="save" v-if="(base.step == 1 || base.step == 2) && !recheck" @click="repulse">打回</a>
                        <a class="submit" @click="submitResult" v-show="!(base.step != 0 && !!recheck)">提交</a>
                    </b>
                    <b class="operations" v-show="history.showVersionInfo">
                        <a class="save" @click="closeVersion">返回</a>
                        <a class="submit" @click="recoverVersion(null)">恢复到该版本</a>
                    </b>
                </b>
            </div>

            <div class="getsuccess" v-if="history.getSuccess">
                <div class="bg"></div>
                <div class="showpop">
                    <div class="applytask">领取成功!现在去做任务？</div>
                    <div class="btn" id="btn">
                        <a class="yes" @click="executNow">立即执行</a>
                        <a class="no" @click="closeResult">暂不执行</a>
                    </div>
                </div>
            </div>
            <div class="getsuccess" v-if="history.submitsuccess">
                <div class="bg"></div>
                <div class="showpop">
                    <div class="applytask">提交成功！</div>
                    <div class="btn" id="btn">
                        <a class="yes" @click="joinTask">领取下一条</a>
                        <a class="no" @click="closeResult">退出</a>
                    </div>
                </div>
            </div>
            <div id="pop" v-if="history.hidePop">
                <div class="layer"></div>
                <div class="show_pop bdradius">
                    <div class="poptitle">
                        <span class="fs14_bold">申请任务</span>
                    </div>
                    <div id="pop_con">
                        <div class="inputcon">
                            <ul>
                                <li>
                                    <div class="label">任务类型</div>
                                    <div class="lab_con">
                                        <span :class="{select: task_type == 'mark'}" @click="changeTab('mark')">标注任务</span>
                                        <span class="grey" style="display: none">检查任务</span>
                                        <span :class="{select: task_type == 'check'}" @click="changeTab('check')">检查任务</span>
                                    </div>
                                </li>
                                <li v-show="task_type == 'mark'">
                                    <div class="label">申请数量</div>
                                    <div class="lab_con">
                                        <input class="applyweight" v-model="countVal" id="apply-input" type="number" name="lab_val" :placeholder="single_min +  '-'  + single_max" v-show="task_type=='mark' && apply_type == 'custom'" />
                                        <select class="applyweight" name="apply-select" id="apply-select" v-model="countVal" v-if="task_type=='mark' && apply_type == 'gradient'">
                                            <option :value="level" v-for="(level, key) in count_level" :key="key">{{level}}</option>
                                        </select>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        <div class="btngroup">
                            <a class="yes" @click="apply">确定</a>
                            <a class="no" @click="closeResult">取消</a>
                        </div>
                    </div>
                </div>
            </div>

            <!-- 历史 -->
            <div class="pop" v-if="history.show">
                <div class="layer"></div>
                <div class="show_pop hislt">
                    <div class="poptitle">
                        <i @click="history.show = false"></i>
                        <span class="fs14">历史</span>
                    </div>
                    <div class="contain">
                        <table width="100%">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>是否自动保存</th>
                                    <th>版本</th>
                                    <th>结果</th>
                                    <th>时间</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr v-if="history.list[0]" v-for="(item,index) in history.list" :key="index">
                                    <td>{{index + 1}}</td>
                                    <td>{{!!item.autoSave ? '自动' : '手动'}}</td>
                                    <td>{{item.version}}</td>
                                    <td>
                                        <a class="zx-op_rem-btn" @click="viewVersion(item)">查看结果</a>
                                    </td>
                                    <td width="100">{{item.createTime | toDateTime}}</td>
                                    <td>
                                        <a class="zx-op_rem-btn" @click="recoverVersion(item)">恢复到该版本</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div class="head-info" :class="{topHide : arrowShow}" @dragover="listUpMousewheel($event)">
            <div class="info">
                <div class="info_one">
                    <div class="info_one_left" @click="listShow = !listShow">
                        <i class="manue" :class="{seleted : listShow}"></i>
                        <span>文件序列</span>
                        <span style="padding-left:4px;" v-if="files.current">: {{files.current.index * 1 + 1}}</span>
                    </div>
                    <div class="info_one_right">
                        <i class="schedule"></i>
                        <span class="markpro">标注进度：
                            <span class="fs14">{{finishNum}}</span>/{{files.allInfo.length}}</span>
                    </div>
                    <i class="divide"></i>
                </div>
                <div class="info_two">
                    <div class="info_two_one" @click="!history.showVersionInfo && selectData(1)">
                        <i :class="{selected : files.showType == 1}"></i>
                        <span :class="{unclickable : !!!dataLength[0]}">全部</span>
                    </div>
                    <div class="info_two_two" @click="!history.showVersionInfo && selectData(2)">
                        <i :class="{selected : files.showType == 2}"></i>
                        <span :class="{unclickable : !!!dataLength[1]}">好数据</span>
                    </div>
                    <div class="info_two_three" @click="!history.showVersionInfo && selectData(3)">
                        <i :class="{selected : files.showType == 3}"></i>
                        <span :class="{unclickable : !!!dataLength[2]}">坏数据</span>
                    </div>
                    <div class="info_two_four" @click="!history.showVersionInfo && selectData(4)">
                        <i :class="{selected : files.showType == 4}"></i>
                        <span :class="{unclickable : !!!dataLength[3]}">未标注</span>
                    </div>
                    <b class="divide"></b>
                </div>
                <div class="info_three">
                    <div class="info_three_one" @click="pre">
                        <i></i>
                        <span>上一张</span>
                    </div>
                    <div class="info_three_two" @click="next">
                        <i></i>
                        <span>下一张</span>
                    </div>
                    <div class="info_three_three" v-if="files.current" @click="markBadData">
                        <i></i>
                        <span>{{files.current.isBad == 1 ? '标为好数据' : '标为坏数据'}}</span>
                    </div>
                </div>
                <div class="info_four">
                    <i class="divide"></i>
                    <i class="info_four_top" :class="{arrowShow : arrowShow}" @click="arrowShow =! arrowShow"></i>
                </div>
            </div>
        </div>
        <div class="content" :class="{tophide : arrowShow}">
            <div class="content_left" @click.stop="cententLeftFn">
                <div class="file_list" :class="{listHide : listShow}">
                    <div class="file_out_box">
                        <div class="file_in_box">
                            <ul v-if="files.current">
                                <li :class="{good : item.status == 1, bad : item.isBad == 1, sel : item.id == files.current.id}" v-for="(item, index) in files.showList" @click="skipFile(item)" :key="index" :title="item.name">
                                    <span>{{index + 1}}. </span>{{item.name}}</li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="name_tip" v-if="files.current" :class="{yc : tipYc}" @mouseover="tipYc = false" @mouseleave="tipYc = true">{{files.current.name}}</div>
                <div class="content_left_top" id="drawing"></div>
                <div class="content_left_bottom">
                    <div class="content_bottom_one">
                        <div class="zoom">
                            <i></i>
                            <span>{{vm.zoom|takeTwoDecimal}}</span>
                        </div>
                        <div class="rotate_out" @click="setImgRotate">
                            <i></i>
                            <span>{{vm.rotateDeg === 2 ? '90' : vm.rotateDeg === 3 ? '180' : vm.rotateDeg === 4 ? '270' : '0'}} °</span>
                        </div>
                        <div class="mdfigy_rate_out" :class="{sel : modifyTipsShow}" @click="modifyTipsShow = !modifyTipsShow">
                            <i></i>
                            <span>修改率: {{pageModifyRate ? singleModifyRate : averageModifyRate}}%</span>
                        </div>
                    </div>
                    <div class="content_bottom_two">
                        <div class="number" style="margin-right: 56px;">
                            <span>快速弹框 ：</span>
                            <label for="blBox" class="switch-cp">
                                <input id="blBox" class="switch-cp__input" v-model="checkboxsGroup.showEditPop" type="checkbox" :disabled="history.showVersionInfo">
                                <div class="switch-cp__box" :class="{'switch-cp__box2' : checkboxsGroup.showEditPop}"></div>
                            </label>
                        </div>
                        <div class="number" style="margin-right: 56px;">
                            <span>继承层级 ：</span>
                            <label for="switchCJ" class="switch-cp">
                                <input id="switchCJ" class="switch-cp__input" v-model="checkboxsGroup.hierarchy" type="checkbox" :disabled="history.showVersionInfo" @click="(!history.showVersionInfo && !history.show) && inheritHierarchy()">
                                <div class="switch-cp__box" :class="{'switch-cp__box2' : checkboxsGroup.hierarchy}"></div>
                            </label>
                        </div>
                        <div class="number">
                            <span>显示编号：</span>
                            <label for="switchCP" class="switch-cp">
                                <input id="switchCP" class="switch-cp__input" v-model="checkboxsGroup.serial" type="checkbox" :disabled="history.showVersionInfo" @click="(!history.showVersionInfo && !history.show) && showTextContent()">
                                <div class="switch-cp__box" :class="{'switch-cp__box2' : checkboxsGroup.serial}"></div>
                            </label>
                        </div>
                        <div class="inherit">
                            <span>继承属性：</span>
                            <label for="switch" class="switch-cp">
                                <input id="switch" class="switch-cp__input" v-model="checkboxsGroup.inHeritAttr" type="checkbox" :disabled="history.showVersionInfo">
                                <div class="switch-cp__box" :class="{'switch-cp__box2' : checkboxsGroup.inHeritAttr}"></div>
                            </label>
                        </div>
                    </div>
                </div>
                <transition name="zoomIn">
                    <div class="self_popup_wrapper" id="self_popup_wrapper" v-show="poppupShow && vm.currentDrawData.region != 'polyline'" @click.stop @mousedown="popupDrag">
                        <div class="self_popup_in">
                            <textarea class="self_popup_textarea" style="max-height: 300px" v-model="vm.currentDrawData.text" @mousedown.stop @mouseup="textareaMouseUpFn($event)" @mousedown="banDrop = true" @input="textareaIpt" @blur="textareaBlur($event)" @focus="textareaFocus = true" :readonly="isReadOnly(vm.currentDrawData)"></textarea>
                            <!--style="font-size:14px;font-weight: 800;font-family: '宋体';"-->
                            <div class="inset_txt_out">
                                <ul>
                                    <li v-for="(val, key) in fastInsertTxtObj" @click="fastInsertFn(val, key)" :title="val" :key="key">{{val}}</li>
                                </ul>
                            </div>
                            <div class="self_sign_out">
                                <span :class="{seleted : ename == vm.currentDrawData.type}" v-for="(cname, ename) in checkType" @click="selectTag(ename, cname)" :title="cname" :key="ename">{{cname}}</span>
                            </div>
                        </div>
                    </div>
                </transition>
                <div class="point_set_sign_wrapper" v-show="pointPopupShow" @click.stop>
                    <div class="ponit_in_box">
                        <span class="l" @click="setPointSign('top')">上边界点</span>
                        <span class="c" @click="setPointSign('bottom')">下边界点</span>
                        <span class="r" @click="setPointSign('normal')">普通点</span>
                        <span class="jt"></span>
                    </div>
                </div>
                <div class="modify_rate_tips_out" v-show="modifyTipsShow">
                    <i v-if="files.current">
                        <span>标注修改率: {{pageModifyRate ? vm.currentDrawData.markModifyRate : base.step === 0 ? averageModifyRate : files.current.averageRate1 }}%</span>
                        <span v-if="base.step === 1 || base.step === 2">检查修改率: {{pageModifyRate ? vm.currentDrawData.checkModifyRate : base.step === 1 ? averageModifyRate : files.current.averageRate2 }}%</span>
                        <span v-if="base.step === 2">质检修改率: {{pageModifyRate ? vm.currentDrawData.qualityModifyRate : base.step === 2 ? averageModifyRate : files.current.averageRate3 }}%</span>
                    </i>
                </div>
            </div>
            <div class="content_right" :class="{cls : isRightCls}">
                <div class="content_right_one">
                    <div class="content_right_one_top">
                        <div class="right_top_icon"></div>
                        <div class="rectangle" title="矩形 (A)">
                            <i @click="sendclickType(1)"></i>
                        </div>
                        <div class="polygon" title="多边形 (Z)">
                            <i @click="sendclickType(2)"></i>
                        </div>
                        <i class="whippletree"></i>
                    </div>
                    <div class="content_right_one_bottom">
                        <div class="right_bottom_icon"></div>
                        <div class="multiple_choice" title="解答题转写">
                            <i @click="sendclickType(5, 'jieda')"></i>
                        </div>
                        <div :class="{machine : true}" class="machine1" title="速算题转写">
                            <i @click="sendclickType(5, 'susuan')"></i>
                        </div>
                        <div :class="{machine : true}" class="machine2" title="填空题转写">
                            <i @click="sendclickType(5, 'tiankong')"></i>
                        </div>
                        <div :class="{machine : true}" class="machine3" title="自然场景转写">
                            <i @click="sendclickType(5, 'zrcj')"></i>
                        </div>
                        <div :class="{machine : true}" class="machine4" title="辅助转写">
                            <i @click="sendclickType(5, 'fuzhu')"></i>
                        </div>
                    </div>
                    <span class="ck_r_btn" :class="{cls : isRightCls}" @click="isRightCls = !isRightCls"></span>
                </div>
                <div class="content_right_two" @scroll="scroll($event)">
                    <div class="content_lebal_one_outbox">
                        <div class="content_lebal_one" :id="item.id + '_list'" :class="{ select : item.id == vm.selectId, shadow : item.alias.split('-').length > 1 && item.id != vm.selectId}" @dragend="dragend($event)" :draggable="!filterBoxShow && !banDrop" @dragstart="dragStart($event, item)" :ref="'srl'+index" v-for="(item,index) in showList" :key="index" v-show="!item.isFirst && (interactive.screeningTag.length == 0 || interactive.screeningTag.indexOf(item.type) != -1)">
                            <div class="box" :class="{top : item.id + 's' == selDrapClass}" @dragover.stop="addHoverClass($event, item, 's')" @dragleave="dragleave($event)" @drop="changeOrder2(item)">
                                <div class="ins" :class="{listCldSty : item.alias.split('-').length == 2, listCldSty_2 : item.alias.split('-').length == 3, listCldSty_3 : item.alias.split('-').length == 4, seleted : item.id == vm.selectId}"></div>
                            </div>
                            <div class="clear_both" style="padding: 10px 0;" :class="{listCldSty2 : item.alias.split('-').length > 1, listCldSty_2 : item.alias.split('-').length == 3, listCldSty_3 : item.alias.split('-').length == 4,seleted : item.id == vm.selectId}" @dragover.stop="addHoverClass($event, item, 'i')" @dragleave="dragleave($event)" @drop="pushChildren(item)">
                                <div class="content_lebal" @click="selAttrFn($event, index, item)">
                                    <i :class="{bg1 : item.region == 'rect', bg2 : item.region == 'area', bg3 : item.region == 'polyline' }"></i>
                                    <span class="lebal" :title="item | attrTitle">{{!!item.type ? checkType[item.type] : item.unfold ? "" : item.text}}</span>
                                    <a :title="item.alias">{{item.alias}}</a>
                                    <div class="textCope" style="font-size: 14px;" v-show="!item.unfold && !!item.type && !!item.text">{{item.text}}</div>
                                </div>
                                <div class="lebal_list" v-show="item.unfold">
                                    <textarea v-model="item.text" @mouseup="textareaMouseUpFn($event)" @mousedown="banDrop = true" @input="textareaIpt" :ref="item.id" @blur="textareaBlur($event, item)" :readonly="history.showVersionInfo || isReadOnly(item)"></textarea>
                                    <!--style="font-size:14px;font-weight: 800;font-family: '宋体';"-->
                                    <ul>
                                        <li v-for="(val, key) in fastInsertTxtObj" @click="fastInsertFn(val, key, item)" :key="key" :title="val">{{val}}</li>
                                    </ul>
                                </div>
                            </div>
                            <div class="box" @dragover.stop="addHoverClass($event, item, 'x')" :class="{bottom : item.id + 'x' == selDrapClass}" @dragleave="dragleave($event)" @drop="changeOrder2(item, 'down')">
                                <div class="ins" :class="{listCldSty : item.alias.split('-').length == 2, listCldSty_2 : item.alias.split('-').length == 3, listCldSty_3 : item.alias.split('-').length == 4,seleted : item.id == vm.selectId}"></div>
                            </div>
                            <div class="drop_in_sel" v-show=" item.id + 'i' == selDrapClass"></div>
                        </div>
                    </div>
                </div>
                <div class="right_bt_box" @dragover="listDownMousewheel($event)">
                    <span class="del" @click="delectSelectBox" title="删除"></span>
                    <span class="sx" @click="sxFn" title="筛选"></span>
                </div>
                <div class="sx_sel_box" v-show="filterBoxShow">
                    <div class="sx_top_box">
                        <span class="txt">筛选</span>
                        <span class="icon" @click="changeScreeningCls"></span>
                    </div>
                    <ul>
                        <li :class="{seleted : interactive.screeningTag.indexOf(ename) != -1}" v-for="(cname, ename) in checkType" :key="ename" @click="changeScreening(ename, cname)" :title="cname">{{cname}}</li>
                    </ul>
                </div>
                <div class="lebal-lebals" ref="lebals" v-show="JSON.stringify(checkType) != '{}' && lebalLebals">
                    <span :class="{seleted : ename == vm.currentDrawData.type}" v-for="(cname, ename) in checkType" :key="ename" @click="selectTag(ename, cname)" :title="cname">{{cname}}</span>
                </div>
            </div>
        </div>
        <!-- <Dialogs>
            <EditFrom :editCfg='comfimProps.editCfg'
                :editData='comfimProps.editData' ref='editForm  '></EditFrom>
        </Dialogs> -->
    </div>
</template>

<script>
import PageSize from "@/assets/js/pagesize.js"; // 分页插件
import SVG from "svg.js" // svg图形操作插件
import OcrPublicClass from "@/assets/plugin/jingxihuaocr.js" // ocr业务功能插件
import CompareTxtNew from "@/assets/plugin/compare.js"  // 文本对比插件

let self = null;
let svg = null;
export default {
    name: "mark-page",
    data() {
        return {
            taskId: "",
            markTaskId: "",
            recheck: null,
            base: {
                markName: "",
                markStandard: "",
                markTaskId: "",
                batchId: "",
                step: 0
            },
            files: {
                // 文件信息
                lastIndex: 0, // 上次标注的文件id
                allInfo: [], // 全部数据
                showType: 0, // 1 表示全部 2 表示好数据，3表示坏数据，4表示未标注
                showList: [],
                current: null, // 当前的数据
                curIndex: 0, // 当前数据的id
                allImage: [], // 全部的图片
                currentPoint: null // 给点添加标签 新增字段
            }, // 文件相关
            history: {
                show: false, //历史界面显示
                list: [], //历史文件列表
                allList: [],
                curIndex: 0,
                showVersionInfo: false, //历史显然界面显示
                textData: "", // 历史规整内容字符串
                correlationHTML: "", //历史联动内容字符串
                unfoldDomH: {},
                curFiles: null, //当前选中历史记录的文件对象
                hidePop: false,
                getSuccess: false,
                submitsuccess: false
            },
            comfimProps: {
                editCfg : [{
                    type : 'radio', // textarea
                    label: '质检结果:',
                    prop : 'c_submit1',  // editData[prop] == modelTxt
                    width : '100px',
                    change : function(val){
                    }, // change回调
                    radios: [{// type == radio 单选
                        label: '合格',
                        value : 1
                    },{
                        label: '不合格',
                        value : 2
                    }],
                },{
                    type : 'textarea', // textarea
                    label: '评价:',
                    prop : 'c_submit2',  // editData[prop] == modelTxt
                    width : '260px'
                }],
                editData: { // 数据对象
                    'c_submit1' : 1,
                    'c_submit2' : '1232'
                },
                editRules: { // 校验规则

                }
            },
            arrowShow: false,
            listShow: true,
            lastType: "click", // 上次选择的绘图类型
            checkboxsGroup: {
                serial: false,
                inHeritAttr: false,
                hierarchy: false,
                showEditPop: false // 绘制完弹弹框 // 快速弹框
            },
            filterBoxShow: false, //筛选框显示
            lebalLebals: false, //选择属性框显示
            checkType: {},
            fastInsertTxtObj: {},
            drapSrlDom: null, // 拖拽区域中的拖拽d元素om
            promptShow: {
                shortcuts: false, // 快捷键
                standard: false, // 规范显示
                selFiles: 1
            },
            interactive: {
                screeningShow: false, // 是否显示筛选框
                screeningTag: [], // 需要筛选的属性
                saveSuccess: true, // 当前数据保存是否成功
                currentFinished: false // 当前图片是否加载完毕
            }, // 交互相关
            vm: {
                // 配置参数
                leaveEnd: false,
                el: "drawing", // SVG 挂载点
                height: "100%", // SVG 渲染高度
                width: "100%", // SVG 渲染宽度
                type: "click", // 当前绘图的类型
                currentDrawData: {}, // 当前绘制图形的属性值
                currentId: 0, // 当前标注的文件序列 唯一不重复即可
                selectId: "", // 当前选中的 SVG 图像的id  主要为了获取当前选择的图形id
                list: [], // 图形数据 由于层级关系 需要用到
                isDisableRightKey: true, // 是否禁用右键
                zoom: 1, // 缩放比例
                maxZoom: 15, // 最大缩放比例
                minZoom: 0.02, // 最小缩放比例
                strokeWidth: 2, // 生成线的大小
                dragPointSize: 10, // 拖拽点的 大小
                textSize: 12, // 文本默认大小
                rotateDeg: 1, // 0 0, 1 90, 2 180 , 3  270,
                imgData: {
                    // 图片的基本信息
                    imgPath:
                        "http://ainote.iflytek.com/static/images/reg_bg.jpg", // http://127.0.0.1:8081/static/img/test.3036edb.jpg
                    width: 0,
                    height: 0,
                    x: 0,
                    y: 0
                },
                canChooseP: true, //是否开启选中多边形呢的折线
                svgHightLightClass: "svg-highlight", // 高亮的calss
                currentPolyLineId: "", // 当前折线的id
                clickCallBack: this.setClick, // 点击的回掉函数
                successCallBack: this.successCallBack, // 绘图结束后的回掉
                drawFailCallBack: this.drawFailCallBack, // 绘制失败回调
                imgLoadCallBack: this.imgLoadCallBack, // svg img绘图成功后的回调
                changeCallBack: this.changeCallBack, // 图形修改后的回调
                pointMouseDown: this.pointCallBack,
                svgNodeClickCallBack: this.svgNodeClickCallBack, // svg单击回调函数
                svgNodeDblclickCallBack: this.svgNodeDblclickCallBack, // svg双击回调函数
                pointContextmenuCallback: this.pointContextmenuCallback, // 点右击事件
                dragPointMoveCallback: this.dragPointMoveCallback, // 拖拽点移动回调
                graphicsMoveCallback: this.graphicsMoveCallback // 图形移动回调
            },
            refresh: 0, // 参考参数
            temItem: null, // 拖拽中间数据源
            successNum: 0, // 序列号
            preListsObj: null, // 保存上一个操作的list列表中图形信息对象 避免遍历
            selDrapClass: "",
            copeAttrCnt: "",
            cursorLocation: 0, // 光标的位置 供快速插入使用
            operate: {
                autoSaveInterval: null, // 定时器自动保存
                isKeydownPrepare: true // 输入框是否获取焦点，默认没有
            },
            drawOver: false,
            ctrlDown: false,
            requiredLabel: true,
            isTranscription: true,
            isPointLabel: true, // 必须给点打标签
            banDrop: false,
            roboting: false, //机器转写
            tipYc: true, // tip隐藏
            hierarchyId: "", // 继承层级的ID
            downCanWheel: true, // 可以上滑动标识
            upCanWheel: true, // 可以下滑动标识
            poppupShow: false, // 快速编辑弹框展示
            pointPopupShow: false, // 点标记框展示
            isRightCls: false, // 关闭右边区域
            modifyTipsShow: false, // 修改率浮层
            textareaFocus: false, //
            markAverageRate: "--", // 标注环节平均修改率
            checkAverageRate: "--", // 检查环节平均修改率
            qualityAverageRate: "--", // 质检环节平均修改率
            readOnly: ["not-care","other-language","Korean","formula","apostrophe","machineprint"], // readOnly的属性 machineprint 印刷
            MytaskList: "",
            task: {},
            task_type: "mark",
            apply_type: "custom",
            single_min: 0,
            single_max: 0,
            count_level: [],
            countVal: null,
            currPage: 1,
            pageSize: 10,
            postData: {
                taskType: "", //任务类型：0-标注任务；1-检查任务；2-质检任务
                progressType: "0", //任务完成情况：0-未完成；1-已完成
                taskName: "", //任务名称
                taskStatus: ""
            }
        };
    },
    // 同步原始数据拉取
    async created() {
        self = this;
        self.taskId = self.Utils.getQueryStringArgs()["taskId"];
        //markTaskId
        self.markTaskId = self.Utils.getQueryStringArgs()["markTaskId"];

        if (self.Utils.getQueryStringArgs().recheck === "recheck") {
            self.recheck = 1;
        } else {
            self.recheck = 0;
        }
        // ass_api.getFileInfo(markTaskId, function (info) {
        self.taskId = "C4A9347E78DF44F0AC06294426402893";
        self.markTaskId = "659EF05C67C040A3BA6D514B49C44955";
        const getFileListPromise = self.ass_api.getFileListNew({
            // 复检功能
            markTaskId: self.markTaskId,
            markFileId: "all",
            recheck: self.recheck
        })
        await getFileListPromise.then(info => {
                if(!info) return;
                info = JSON.parse(info);
                var step = info.step;
                console.log(info);
                if (!(step == 0 || step == 1 || step == 2)) return self.ui.error('获取文件异常');
                if (info.files.length == 0) return self.ui.error("获取文件个数为0");

                self.base.step = step;
                self.base.batchId = info.batchId;
                self.base.markStandard = info.markStandard;
                self.base.markName = info.markName; // 任务名称
                self.base.markTaskId = info.markTaskId;
                self.requiredLabel = info.pageElement.requiredLabel; // 是否必选标签
                self.isTranscription = info.pageElement.isTranscription; // 是否必选转写
                self.isPointLabel = info.pageElement.isPointLabel; // 是否给点打标签

                if (step == 0) {
                    $("title").text("精细化标注");
                } else if (step == 1) {
                    $("title").text("精细化检查");
                } else if (step == 2) {
                    $("title").text("精细化质检");
                }

                var files = info.files; // 过滤出后台返回来的files
                var lastIndex = info.lastIndex * 1;

                // self.getCurResult(self.files.allInfo[self.files.curIndex]) // 获取最新数据 同步
                var labels = info.pageElement.labels;
                for (let i = 0; i < labels.length; i++) {
                    self.fastInsertTxtObj[labels[i].ename] = labels[i].cname;
                }
                for (let i = 0; i < info.pageElement.propertyLabels.length; i++) {
                    self.checkType[info.pageElement.propertyLabels[i].ename] = info.pageElement.propertyLabels[i].cname;
                }

                self.initFiles(info.files, info.lastIndex);
                // self.operate.autoSaveInterval = setInterval(function() {
                //     // 20s一次 查看历史的时候跳过执行
                //     if (!( self.history.show == true || self.history.showVersionInfo == true)) {
                //         // self.getCurrentFocusElement() 新方案 不需要
                //         self.saveCheckData(true) && self.saveResult(true, true); // 自动，异步
                //     }
                // }, 20000);
            })
            // 快捷键事件绑定
            this.shortcutKeyEvent()
    },
    mounted() {
        document.documentElement.addEventListener("contextmenu", function(e) {
            if (self.drawOver) {
                self.drawOver = false;
                return;
            }
            self.delectSelectBox(true);
        });
    },
    computed: {
        // 新增
        showList: function() {
            // 展示的
            this.refreshList();
            var info = [],
                re = this.refresh;
            setRightList(this.vm.list, info);

            function setRightList(data, info) {
                data.forEach(function(data, index) {
                    if (data.children) {
                        info.push(data);
                        setRightList(data.children, info);
                    } else {
                        info.push(data);
                    }
                });
            }
            return info;
        },
        finishNum: function() {
            // 查看标注完成个数
            var len = this.files.allInfo.length,
                result = 0;
            if (len == 0) return "--";
            for (var i = 0; i < len; i++) {
                if (this.files.allInfo[i].status == 1) {
                    result++;
                }
            }
            return result;
        },
        dataLength: function() {
            var dataL = [0, 0, 0, 0];
            if (!this.files || !this.files.allInfo) {
                return dataL;
            }
            var len = this.files.allInfo.length,
                info = this.files.allInfo;
            dataL[0] = len;
            for (var i = 0; i < len; i++) {
                if (info[i].isBad === 0) {
                    //好数据
                    dataL[1]++;
                }
                if (info[i].isBad === 1) {
                    // 坏数据
                    dataL[2]++;
                }
                if (info[i].status === 0) {
                    // 未标注
                    dataL[3]++;
                }
            }
            return dataL;
        },
        pageModifyRate: function() {
            // 页面要展示的修改率  bcjia 修改
            if (/^p-|^r-\d/g.test(this.vm.selectId)) {
                return true;
            } else {
                return false;
            }
        },
        averageModifyRate: function() {
            // 平均修改率
            var sumModify = 0,
                val = "";
            if (this.showList) {
                this.showList.forEach(function(item) {
                    sumModify +=
                        self.base.step === 0
                            ? item.markModifyRate
                            : self.base.step === 1
                                ? item.checkModifyRate
                                : self.base.step === 2
                                    ? item.qualityModifyRate
                                    : "";
                });
            }
            val = parseInt(sumModify / this.showList.length * 100) / 100;
            val = val ? val : 0;
            if (self.base.step === 0) {
                this.markAverageRate = val;
            } else if (self.base.step === 1) {
                this.checkAverageRate = val;
            } else if (self.base.step === 2) {
                this.qualityAverageRate = val;
            }
            return val;
        },
        singleModifyRate: function() {
            if (self.base.step === 0) {
                return this.vm.currentDrawData.markModifyRate;
            } else if (self.base.step === 1) {
                return this.vm.currentDrawData.checkModifyRate;
            } else if (self.base.step === 2) {
                return this.vm.currentDrawData.qualityModifyRate;
            }
        }
    },
    methods: {
        shortcutKeyEvent() {
            document.onkeydown = function(e) {
                // keydown事件
                // if(self.operate.isKeydownPrepare === false) return;
                var e = e || window.event,
                    code = e.keyCode || e.which || e.charCode;

                var type = e.srcElement ? e.srcElement.type : e.target.type; // 看当前所处环境
                var ableToDo = true; // 用来区分是否可以使用快捷键
                var upDown = true; // 是否可以 上下 切换 2018/9/28
                if (type === "text" || type === "textarea") {
                    // 如果在文本框中
                    ableToDo = false;
                }

                // self.rectanglePolygon(self.vm.selectId);
                if (type === "textarea") {
                    // 如果在 textarea 中 2018/9/28
                    upDown = false;
                }
                self.Utils.shortKeyIfTrue(
                    code == 90 && ableToDo,
                    function() {
                        // shift + z  多边形 e.shiftKey && code == 90
                        if (e.ctrlKey) return;
                        self.sendclickType(2);
                    },
                    e
                );
                self.Utils.shortKeyIfTrue(
                    code == 9 && ableToDo,
                    function() {
                        // 快速编辑快捷键 code == 9 Table
                        if (e.ctrlKey) return;
                        if (
                            !self.poppupShow &&
                            self.vm.selectId != "defaultGroup"
                        ) {
                            // 打开弹窗
                            self.svgNodeDblclickCallBack({
                                offsetX: 0,
                                offsetY: 0
                            });
                        } else {
                            // 关闭弹窗
                            self.poppupShow = false;
                        }
                    },
                    e
                );

                self.Utils.shortKeyIfTrue(
                    code == 65 && ableToDo,
                    function() {
                        // shift + z  矩形  e.ctrlKey && self.mouseState === 1
                        if (e.ctrlKey) return;
                        self.sendclickType(1);
                    },
                    e
                );
                self.Utils.shortKeyIfTrue(
                    code == 32 && ableToDo,
                    function() {
                        // 拖拽 115 code == 32
                        if (e.ctrlKey) return;
                        self.sendclickType(6);
                    },
                    e
                );
                self.Utils.shortKeyIfTrue(
                    code == 69 && ableToDo,
                    function() {
                        // 下一条 e
                        self.next();
                    },
                    e
                );
                self.Utils.shortKeyIfTrue(
                    code == 81 && ableToDo,
                    function() {
                        // 上一条 q
                        self.pre();
                    },
                    e
                );
                self.Utils.shortKeyIfTrue(
                    code == 83 && ableToDo,
                    function() {
                        // 筛选框 s
                        self.filterBoxShow = !self.filterBoxShow;
                    },
                    e
                );
                // self.Utils.shortKeyIfTrue(code == 88 && ableToDo, function () { // 折线 x
                //     if(e.ctrlKey) return;
                //     self.sendclickType(3);
                // }, e);
                self.Utils.shortKeyIfTrue(
                    code == 13 && ableToDo,
                    function() {
                        // 快速编辑 选中 + Enter
                        self.quickEditFn();
                    },
                    e
                );

                self.Utils.shortKeyIfTrue(
                    code == 67 && ableToDo,
                    function() {
                        // 继承层级
                        if (self.history.showVersionInfo || self.history.show)
                            return;
                        self.checkboxsGroup.hierarchy = !self.checkboxsGroup
                            .hierarchy;
                        self.inheritHierarchy();
                    },
                    e
                );

                self.Utils.shortKeyIfTrue(
                    code == 27 && ableToDo,
                    function() {
                        // 取消绘图 Y
                        svg.cancelDraw(); // 取消正在绘制
                        svg.initCursor(); // 初始化光标
                        self.drawOver = true;
                        self.vm.type = "click"; // 初始化绘制类型
                        self.lastType = "click"; // 初始化上次绘制类型
                    },
                    e
                );
                self.Utils.shortKeyIfTrue(
                    e.ctrlKey && code == 90 && ableToDo,
                    function() {
                        //  撤销折线控制点 ctrl + z
                        svg.revokePolygon();
                    },
                    e
                );
                self.Utils.shortKeyIfTrue(
                    e.ctrlKey && ableToDo,
                    function() {
                        //  ctrl键按下
                        self.ctrlDown = true;
                    },
                    e
                );
                self.Utils.shortKeyIfTrue(
                    code == 46 && ableToDo,
                    function() {
                        if (self.drawOver) {
                            self.drawOver = false;
                            return;
                        }
                        self.delectSelectBox(true);
                    },
                    e
                );
            };

            document.onkeyup = function(e) {
                // keyup事件
                var e = e || window.event,
                    code = e.keyCode || e.which || e.charCode;
                var type = e.srcElement ? e.srcElement.type : e.target.type; // 看当前所处环境
                var ableToDo = true; // 用来区分是否可以使用快捷键
                self.ctrlDown = false;
                if (type === "text" || type === "textarea") {
                    // 如果在文本框中
                    ableToDo = false;
                }
                // 空格
                self.Utils.shortKeyIfTrue(
                    code == 32 && ableToDo,
                    function() {
                        // 拖拽 115 code == 32
                        self.sendclickType(self.lastType);
                    },
                    e
                );
            };
        },
        robot: function() {
            var url = "/open/robot";
            window.open(url);
        },
        // 禁止文本输入框，输入文字
        isReadOnly: function(item) {
            if (this.readOnly.indexOf(item.type) > -1) {
                return true;
            }
            return false;
        },
        // 计算修改率
        calculateModificationRate: function(item) {
            var itemType = Object.prototype.toString.call(item).slice(8, -1);
            if (itemType === "Array") {
                item.forEach(function(grap) {
                    self.calculateModificationRate(grap);
                });
            } else if (itemType === "Object") {
                var originalTxt = "";
                if (this.base.step === 0) {
                    // 标注环境
                    originalTxt = item.machineTxt;
                } else if (this.base.step === 1) {
                    // 检查环节
                    originalTxt = item.markTxt;
                } else if (this.base.step === 2) {
                    // 质检环节
                    originalTxt = item.checkTxt;
                }

                if (item.children && item.children.length > 0) {
                    // bcjia 如果有子元素
                    self.calculateModificationRate(item.children);
                }

                if (!originalTxt || (originalTxt && !item.text)) {
                    // 没有机器文本 或者 有机器文本 无标注文本 修改率 100
                    this.base.step === 0
                        ? (item.markModifyRate = 100)
                        : this.base.step === 1
                            ? (item.checkModifyRate = 100)
                            : this.base.step === 2
                                ? (item.qualityModifyRate = 100)
                                : "";
                    return;
                }
                if (this.base.step === 0) {
                    item.markModifyRate = CompareTxtNew(
                        originalTxt,
                        item.text
                    ).modifyTate;
                } else if (this.base.step === 1) {
                    item.checkModifyRate = CompareTxtNew(
                        originalTxt,
                        item.text
                    ).modifyTate;
                } else if (this.base.step === 2) {
                    item.qualityModifyRate = CompareTxtNew(
                        originalTxt,
                        item.text
                    ).modifyTate;
                }
            }
        },
        // 矩形转多边形
        rectanglePolygon: function(id, cx, cy) {
            if (/^r-\d+/.test(id)) {
                // 矩形转
                svg.rectToPolygon(id, this.rectanglePolygonByData);
                SVG.select(".adjust-size").each(function() {
                    var cx2 = this.cx(),
                        cy2 = this.cy(),
                        id2 = this.id();
                    if (cx2 === cx && cy2 === cy) {
                        svg.setPointbPoint("", id2);
                    }
                });
            }
        },
        // 矩形转多边形后的处理
        rectanglePolygonByData: function(objDom, oId) {
            var id = objDom.id();
            self.setClick(id); // 设置id
            self.setDrawData(objDom, "conversion", oId);
        },
        // 折线排序 根据父级多边形id
        setLine: function(id, lists) {
            var info = [],
                allLine = [];
            getLine(lists, info);

            function getLine(data, info) {
                data.forEach(function(item, index) {
                    if (item.children && item.children.length > 0) {
                        if (item.pId === id) {
                            allLine.push(item);
                        }
                        getLine(item.children, info);
                    } else {
                        if (item.pId === id) {
                            allLine.push(item);
                        }
                    }
                });
            }
            return this.sortLine(allLine);
        },
        sortLine: function(allLine) {
            var compareArr = [],
                first = [];
            for (var i = 0, len = allLine.length; i < len; i++) {
                if (allLine[i].region === "polyline") {
                    allLine[i].points = self.polygonToNeed(allLine[i].points);
                    compareArr.push([allLine[i].points[0][1], allLine[i].id]); // 获取第一个点的Y
                }
            }
            first = compareArr.sort(sortByY);

            function sortByY(f, s) {
                return f[0] - s[0];
            }

            return this.setSignByLine(allLine, first);
        },
        setSignByLine: function(allLine, first) {
            var firstLine = null;
            for (var i = 0; i < allLine.length; i++) {
                if (allLine[i].id === (first[0] && first[0][1])) {
                    allLine[i].isFirst = true;
                    firstLine = allLine[i];
                } else {
                    allLine[i].isFirst = false;
                }
            }
            self.refresh++;
            return firstLine;
        },
        /**
         * 文本的显示和隐藏
         */
        showTextContent: function() {
            var type = this.checkboxsGroup.serial;
            if (type) {
                self.changeText(this.vm.list);
            } else {
                svg.showText(false);
            }
        },
        /**
         * 继承层级
         */
        inheritHierarchy: function() {
            var hierarchy = this.checkboxsGroup.hierarchy,
                oldHierId = this.hierarchyId;
            this.hierarchyId = this.vm.selectId;

            if (!hierarchy) {
                if (oldHierId && SVG.get(oldHierId)) {
                    SVG.get(oldHierId).removeClass("svg-hierarchy");
                }
            } else {
                // 继承层级条件过滤
                if (this.hierarchyId === "") {
                    // 首先 得有继承的层级图形
                    this.checkboxsGroup.hierarchy = false;
                    this.hierarchyId = oldHierId;
                    return self.ui.fade("未选择需要继承的层级！");
                }
                var vmList = this.showList; // 其次 选择的继承层级图形 还存在 (可能操作中间被删除)
                var hierarchyDom = null;
                if (
                    !vmList.some(function(item) {
                        if (item.id === self.hierarchyId) {
                            hierarchyDom = item;
                        }
                        return item.id === self.hierarchyId;
                    })
                ) {
                    this.checkboxsGroup.hierarchy = false;
                    this.hierarchyId = oldHierId;
                    return  self.ui.fade("继承层级图形不存在");
                }
                if (!hierarchyDom.alias && hierarchyDom.isFirst) {
                    // 第一条折线
                    this.checkboxsGroup.hierarchy = false;
                    this.hierarchyId = oldHierId;
                    return  self.ui.fade("当前父层级为多边形内第一条折线，不允许被继承！");
                }
                if (hierarchyDom.alias.split("-").length >= 4) {
                    // 继承的图形层级不能为四层
                    this.checkboxsGroup.hierarchy = false;
                    this.hierarchyId = oldHierId;
                    return  self.ui.fade("最多嵌套4层,请重新选择继承层级图形");
                }

                if (this.hierarchyId) {
                    SVG.get(this.hierarchyId).addClass("svg-hierarchy");
                }
            }
        },
        /**
         * 展示文本
         */
        changeText: function(data) {
            for (var i = 0; i < data.length; i++) {
                if (data[i].children && data[i].children.length > 0) {
                    self.changeText(data[i].children);
                    if (!data[i].isFirst) {
                        svg.showText(true, data[i].id, data[i].alias);
                    }
                } else {
                    if (!data[i].isFirst) {
                        svg.showText(true, data[i].id, data[i].alias);
                    }
                }
            }
        },
        /**
         * 阻止默认事件
         * @param event
         */
        addHoverClass(event, item, l) {
            var event = event || window.event;
            if (event.preventDefault) {
                event.preventDefault();
            }
            var pAliasLen = this.temItem.alias.split("-").length;
            if (item.alias.slice(0, pAliasLen) === this.temItem.alias) return; // 父元素不能往子元素拖
            this.selDrapClass = item.id + l;
        },
        /**
         * 拖拽开始
         * @param item
         */
        dragStart: function(e, item) {
            if (this.filterBoxShow) {
                self.ui.fade("筛选中禁止拖拽");
            }
            e.dataTransfer.setData("text/plain", "");
            $(e.target).css({
                // 'visibility': 'hidden',
                opacity: 0.6
            });
            $(e.target).children("div").each(function(ind, items) {
                $(items).css({
                    opacity: 0.6
                });
            });
            this.temItem = item; // 获取当前获取元素的引用
        },
        dragend: function(e) {
            $(e.target).css({
                // 'visibility': 'visible',
                opacity: 1
            });
            $(e.target).children("div").each(function(ind, items) {
                $(items).css({
                    opacity: 1
                });
            });
            this.selDrapClass = "";
        },
        /**
         * 移动到上部分
         * @param item
         * @returns {boolean}
         */
        changeOrder2: function(item, type) {
            // 改变当前引用在对象中的位置
            // this.selDrapClass = '';
            if (this.temItem) {
                // 确保存在有效的被拖拽元素
                if (!item.alias || item.alias == 0) {
                    item.alias = "";
                }
                // 父元素不能被拖到子元素中
                if (item.alias.indexOf(this.temItem.alias) === 0) {
                    return false;
                }
                // 折线同级拖拽 源和目标的父层级值必须相同 只能在同父曲线区域内进行拖拽
                if (this.temItem.region == "polyline" && (!item.parent || item.parent.alias != this.temItem.parent.alias)) {
                    self.ui.fade("折线只允许在当前父曲线范围中进行拖拽！");
                    return false;
                }
                // if(item.region == 'polyline' && this.temItem.region != 'polyline'){ // 在存在折线的同级拖拽 如果源图形 不是折线 不进行操作
                //     ui.fade('多边形区域内存在折线，不允许嵌套矩形或多边形！')
                //     return false;
                // }
                // 改变当前对象的数据结构
                this.deleteItem(this.temItem); // 删除源
                var targetList = !item.parent ? this.vm.list : item.parent.children; // 获取目标引用所在的位置

                var inId = this.getItemIndex(targetList, item);
                if (inId != null) {
                    targetList.splice(type === "down" ? inId + 1 : inId, 0, this.temItem);
                }
                // this.refreshList();

                this.refresh++;
            }
        },
        // 拖拽经过
        dragleave: function(e, item, l) {
            this.selDrapClass = "";
        },
        /**
         *  拖拽区域快速上滑
         */
        listDownMousewheel: function(e) {
            if (this.downCanWheel) {
                this.downCanWheel = false;
                var maxTop = $(".content_lebal_one_outbox").height() - $(".content_right_two").height(),
                    scrollTop = $(".content_right_two").scrollTop();
                if (scrollTop < maxTop) {
                    $(".content_right_two").animate({scrollTop : scrollTop + $(".content_right_two").height()},800);
                }
                var Timer = setTimeout(function() {
                    this.downCanWheel = true;
                    clearTimeout(Timer);
                }.bind(this),1000);
            }
        },
        /**
         * 拖拽区域快速下滑
         */
        listUpMousewheel: function(e) {
            if (this.upCanWheel) {
                this.upCanWheel = false;
                var scrollTop = $(".content_right_two").scrollTop();
                if (scrollTop > 0) {
                    $(".content_right_two").animate({scrollTop : scrollTop - $(".content_right_two").height()},800);
                }
                var Timer = setTimeout(function() {
                    this.upCanWheel = true;
                    clearTimeout(Timer);
                }.bind(this),1000);
            }
        },
        /**
         * 数组移除操作
         * @param item
         */
        deleteItem: function(item) {
            // 删除操作
            var tarList2 = !item.parent ? this.vm.list : item.parent.children;
            var rmId = this.getItemIndex(tarList2, item);
            if (rmId != null) {
                tarList2.splice(rmId, 1);
            }
        },
        /**
         * 获取元素位置
         * @param _list
         * @param _item
         * @returns {*}
         */
        getItemIndex: function(_list, _item) {
            var tmIndex = 0;
            for (var i = 0, len = _list.length; i < len; i++) {
                if (_list[i].id == _item.id) {
                    tmIndex = i;
                    break;
                }
            }
            return tmIndex;
        },
        /**
         * 移动到下部分
         * @param item
         * @returns {boolean}
         */
        pushChildren: function(item) {
            this.selDrapClass = "";
            if (this.temItem) {
                if (!item.alias || item.alias == 0) {
                    item.alias = "";
                }
                var num = 0;
                function calcNum(lists) {
                    lists.forEach(function(item) {
                        if (item.children && item.children[0]) {
                            num++;
                            calcNum(item.children);
                        }
                    });
                }
                if (this.temItem.children && this.temItem.children[0]) {
                    num++;
                    calcNum(this.temItem.children);
                }
                // 父级与祖宗元素不能拖到子集元素中
                if (item.alias.indexOf(this.temItem.alias) === 0) {
                    self.ui.fade("父元素不能往子元素拖拽");
                    return false;
                }
                // 最多4层
                if (num + item.alias.split("-").length > 3) {
                    self.ui.fade("最多嵌套四层！");
                    return;
                }

                // 折线不能进行嵌套
                if (this.temItem.region == "polyline") {
                    self.ui.fade("折线只能同级拖拽，不允许嵌套！");
                    return false;
                }
                // if(item.region == 'polyline'){
                //     ui.fade('折线内部不允许嵌套！')
                //     return false;
                // }
                // if (this.temItem.region != 'polyline') {
                //     var children = item.children;
                //     if (children && children[0]) {
                //         for (var i = 0; i < children.length; i++) {
                //             if (children[i].region == 'polyline') {
                //                 ui.fade('多边形区域内存在折线，不允许嵌套矩形或多边形！')
                //                 return;
                //             }
                //         }
                //     }
                // }
                if (!item.children) {
                    // 如果没有children 复制一份
                    item.children = [];
                }
                this.deleteItem(this.temItem);
                item.children.push(this.temItem);

                this.refresh++;
                // this.refreshList();
            }
        },
        /**
         * 数据渲染
         */
        refreshList: function() {
            for (var i = 0, len = this.vm.list.length; i < len; i++) {
                var item = this.vm.list[i];
                if (item.unfold) {
                    // 右侧list列表 是否展开
                    self.$set(item, "unfold", true);
                } else {
                    self.$set(item, "unfold", false);
                }
                if (item.type === undefined) {
                    self.$set(item, "type", "");
                }
                // 设置cid 与 别名
                item.cid = i + 1;
                if (!item.isFirst) {
                    self.$set(item, "alias", i + 1 + "");
                } else {
                    self.$set(item, "alias", "");
                }
                item.parent = null;
                handleChildrenItem(item, item.alias);
            }

            this.successNum = i + 1;
            // this.refresh ++;
            function handleChildrenItem(item, p_alias) {
                var firstId = null; // 每次调用应该是重置
                if (item && item.children && item.children.length != 0) {
                    for (var i = 0, len = item.children.length; i < len; i++) {
                        var c = item.children[i];
                        if (c.unfold) {
                            // 右侧list列表 是否展开
                            self.$set(c, "unfold", true);
                        } else {
                            self.$set(c, "unfold", false);
                        }
                        if (c.type === undefined) {
                            self.$set(c, "type", "");
                        }
                        c.cid = i + 1;
                        c.alias = p_alias + "-" + c.cid;
                        if (i + 1 > firstId && firstId !== null) {
                            c.cid = i;
                        } else {
                            c.cid = i + 1;
                        }

                        if (!c.isFirst) {
                            self.$set(c, "alias", p_alias + "-" + c.cid);
                        } else {
                            self.$set(c, "alias", "");
                            firstId = i + 1;
                        }

                        // 设置父元素
                        c.parent = item;
                        handleChildrenItem(c, c.alias, firstId);
                    }
                }
            }
        },
        /**
         * 数据初始化
         * @param files
         * @param lastIndex
         */
        initFiles: function(files, lastIndex) {
            // 遍历循环全部数据
            var self = this;
            var len = files.length,
                curIndex = 0;
            for (var i = 0; i < len; i++) {
                var item = files[i],
                    dInfo = {};
                var extend = item.extend;
                try {
                    // 标注默认结果
                    dInfo = item.defaultResult;
                    dInfo = dInfo;
                } catch (e) {
                    dInfo = [];
                }

                dInfo.forEach(function(info) {
                    // bcjia  (machineTxt 赋值)
                    info.machineTxt = info.text
                        ? info.text
                        : info.machineTxt ? info.machineTxt : ""; // bcjia 修改
                    info.markTxt = info.markTxt ? info.markTxt : "";
                    info.checkTxt = info.checkTxt ? info.checkTxt : "";
                    info.markModifyRate =
                        info.markModifyRate !== undefined
                            ? info.markModifyRate
                            : "--";
                    info.checkModifyRate =
                        info.checkModifyRate !== undefined
                            ? info.checkModifyRate
                            : "--";
                    info.qualityModifyRate =
                        info.qualityModifyRate !== undefined
                            ? info.qualityModifyRate
                            : "--";
                    info.markAverageRate =
                        info.markAverageRate !== undefined
                            ? info.markAverageRate
                            : "--"; // 标注平均修改率 存在赋值 不存在--
                    info.checkAverageRate =
                        info.checkAverageRate !== undefined
                            ? info.checkAverageRate
                            : "--"; // 检查平均修改率  存在赋值 不存在--
                    info.qualityAverageRate =
                        info.qualityAverageRate !== undefined
                            ? info.qualityAverageRate
                            : "--"; // 质检平均修改率  存在赋值 不存在--
                    try {
                        if (self.readOnly.indexOf(info.type) > -1) {
                            // 如果是5个默认结果 则清空
                            info.text = "";
                        }
                    } catch (e) {}
                });

                var result = this.flatToTreeData(dInfo);

                if (self.Utils.isNotNull(item)) {
                    // 文件不为空 直接赋值到全部数据
                    var url = this.ass_api.getFileUrl({
                        key: "u-" + self.markTaskId + "-" + item.id,
                        sid: self.Utils.getCookie("sid")
                    });
                    self.files.allInfo.push({
                        result: result, // 把扁平数据树结构化 供前端逻辑使用
                        averageRate1: result[0] ? result[0].markAverageRate : "--",
                        averageRate2: result[0] ? result[0].checkAverageRate : "--",
                        averageRate3: result[0] ? result[0].qualityAverageRate : "--",
                        isBad: item.isBad,
                        name: item.name,
                        id: item.id,
                        index: item.id,
                        status: item.status,
                        url: url, // 图片url
                        isInit: 0, // 表示尚未从结果服务获取数据
                        saveSuccess: true
                    });
                    self.files.allImage.push(url); // 所有的图片
                    if (item.id * 1 === lastIndex * 1) {
                        curIndex = i;
                    }
                }
            }

            self.selectData(1, curIndex); // 选择数据
            self.preLoading(self.files.allImage.shift()); // 预加载 img
        },
        /**
         *  图片绘制成功后的回调
         * @param domObject 绘制成功后的图形对象 rect polygon po
         */
        successCallBack: function(domObject) {
            var id = domObject.id(); // 获取对象id
            self.drawOver = true; // 绘制结束标识
            if (this.checkboxsGroup.inHeritAttr && !!this.copeAttrCnt) {
                $(domObject.node).attr("type", this.copeAttrCnt);
            }

            svg.initCursor(); // 初始化光标
            // 是否开启继承层级
            if (this.checkboxsGroup.hierarchy) {
                var vmList = this.showList,
                    hierarchyDom = null;
                // 继承层级条件过滤
                if (this.hierarchyId === "") {
                    // 首先 得有继承的层级图形
                    self.ui.fade("继承层级功能已开启,未选择需要继承的层级！");
                    self.setDrawData(domObject, "add"); // 数据处理
                } else if (
                    !vmList.some(function(item) {
                        if (item.id === self.hierarchyId) {
                            hierarchyDom = item;
                        }
                        return item.id === self.hierarchyId;
                    })
                ) {
                    self.ui.fade("继承层级图形不存在");
                    self.setDrawData(domObject, "add"); // 数据处理
                } else {
                    // 继承层级 的数据操作
                    self.setDrawData(domObject, "push");
                }
            } else {
                // 未开启继承层级 第一次数据列表追加新数据
                self.setDrawData(domObject, "add"); // 数据处理
            }

            self.setClick(id); // 相当于重新触发一次点击事件
            if (this.checkboxsGroup.showEditPop) {
                // 新需求 绘制完成后 快速弹出编辑框 // 快速弹框
                self.svgNodeDblclickCallBack({offsetX: 0, offsetY: 0});
            }
            self.calculateModificationRate(this.vm.currentDrawData); // 计算修改率
            this.vm.type = "click"; // 初始化绘制类型
            this.lastType = "click"; // 初始化上次绘制类型
            if (/^pl-\d+/g.test(id)) {
                // 折线第一条隐藏
                this.setLine(domObject.data("parent"), this.vm.list);
            }
        },
        // svg图形双击
        svgNodeDblclickCallBack: function(e, svgNode) {
            if (self.history.show || self.history.showVersionInfo) return;
            var offsetX = e.offsetX,
                offsetY = e.offsetY;
            var outBoxWidth = $(".content_left").innerWidth(),
                outBoxHeight = $(".content_left").innerHeight();
            var popupWidth = $(".self_popup_wrapper").innerWidth(),
                popupHeight = $(".self_popup_wrapper").innerHeight();

            if (offsetX + popupWidth > outBoxWidth) {
                $(".self_popup_wrapper").css({
                    left: "auto",
                    right: "0px"
                });
            } else if (offsetX - 255 < 0) {
                $(".self_popup_wrapper").css({
                    left: "0px",
                    right: "auto"
                });
            } else {
                $(".self_popup_wrapper").css({
                    left: offsetX - 255 + "px",
                    right: "auto"
                });
            }
            if (offsetY + popupHeight + 60 > outBoxHeight) {
                $(".self_popup_wrapper").css({
                    top: "auto",
                    bottom: "28px"
                });
            } else {
                $(".self_popup_wrapper").css({
                    top: offsetY + 40 + "px",
                    bottom: "auto"
                });
            }

            this.poppupShow = true;
        },
        // 操作点右击
        pointContextmenuCallback: function(e, svgNode) {
            if (self.history.show || self.history.showVersionInfo) return;
            var offsetX = e.offsetX,
                offsetY = e.offsetY;
            var popupBoxWidth = 240,
                popupBoxHeight = 38;
            var parentBoxWidth = $(".content_left").innerWidth(),
                parentBoxHeight = $(".content_left").innerHeight();
            var popupDom = $(".point_set_sign_wrapper");
            this.files.currentPoint = svgNode; // 重置当前操作点元素对象
            if (offsetX + popupBoxWidth > parentBoxWidth) {
                popupDom.css({
                    left: offsetX - 224 + "px"
                });

                $(".jt").css({
                    left: "214px"
                });
            } else {
                popupDom.css({
                    left: offsetX - 14 + "px"
                });
                $(".jt").css({
                    left: "6px"
                });
            }
            if (offsetY < 54) {
                // 小于弹窗的高度 弹窗的小箭头放到上面
                popupDom.css({
                    top: offsetY + 22 + "px"
                });
                $(".jt").css({
                    top: "-10px",
                    transform: "rotateZ(180deg)",
                    "-webkit-transform": "rotateZ(180deg)"
                });
            } else {
                popupDom.css({
                    top: offsetY - 58 + "px"
                });
                $(".jt").css({
                    top: "38px",
                    transform: "none",
                    "-webkit-transform": "none"
                });
            }
            this.pointPopupShow = true;
        },
        svgNodeClickCallBack: function(e) {
            // e.stopPropagation();
        },
        // 拖拽点移动 (bcjia 只针对多边形，矩形点的坐标 和 实际坐标有出入，具体细节没有定位)
        dragPointMoveCallback: function(e, svgNode) {
            var pointType = $(svgNode.node).attr("point-type");
            if (!!pointType && !/^r-\d+/g.test(svgNode.data("parent"))) {
                if (pointType === "startPoint") {
                    self.$set(this.vm.currentDrawData, "startPoint", [
                        svgNode.cx(),
                        svgNode.cy()
                    ]);
                } else if (pointType === "endPoint") {
                    self.$set(this.vm.currentDrawData, "endPoint", [
                        svgNode.cx(),
                        svgNode.cy()
                    ]);
                }
            }
        },
        // 图形移动回调 bcjia
        graphicsMoveCallback: function(e, svgNode) {
            // console.log('movemovemovmemove', svgNode)
            var currentArea = this.vm.currentDrawData,
                startInd = currentArea.startPointInd,
                endInd = currentArea.endPointInd,
                type = currentArea.region, // 图形类型
                pointArr; // 点的集合

            if (type === "rect") {
                currentArea.x = currentArea.x * 1;
                currentArea.y = currentArea.y * 1;
                currentArea.w = currentArea.w * 1;
                currentArea.h = currentArea.h * 1;

                pointArr = [
                    [currentArea.x, currentArea.y],
                    [currentArea.x, currentArea.y + currentArea.h],
                    [currentArea.x + currentArea.w, currentArea.y],
                    [
                        currentArea.x + currentArea.w,
                        currentArea.y + currentArea.h
                    ]
                ];
            }

            if (currentArea.startPoint && startInd >= 0) {
                // 图形存在开始点
                if (type === "area") {
                    pointArr = currentArea.points.split(" ");
                    self.$set(
                        this.vm.currentDrawData,
                        "startPoint",
                        pointArr[startInd].split(",")
                    );
                } else if (type === "rect") {
                    self.$set(
                        this.vm.currentDrawData,
                        "startPoint",
                        pointArr[startInd]
                    );
                }
            }
            if (currentArea.endPoint && endInd >= 0) {
                // 图形存在开始点
                if (type === "area") {
                    pointArr = currentArea.points.split(" ");
                    self.$set(
                        this.vm.currentDrawData,
                        "endPoint",
                        pointArr[endInd].split(",")
                    );
                } else if (type === "rect") {
                    self.$set(
                        this.vm.currentDrawData,
                        "endPoint",
                        pointArr[endInd]
                    );
                }
            }
            // this.closeSignPopup(); // 关闭弹窗
        },
        // 绘制失败回调
        drawFailCallBack: function(failType) {
            this.drawOver = true;
            if (failType === "counterclockwise") {
                return self.ui.fade("请顺时针绘制多边形");
            }
        },
        /**
         * 标记点
         */
        setPointSign: function(type) {
            var currentPoint = this.files.currentPoint,
                currentArea = this.vm.currentDrawData;
            var pointInd = currentPoint.data("point-index");
            if (type === "top") {
                self.$set(this.vm.currentDrawData, "startPoint", [
                    currentPoint.cx(),
                    currentPoint.cy()
                ]);
                self.$set(this.vm.currentDrawData, "startPointInd", pointInd);
                if (
                    currentArea.endPoint &&
                    KeepEight(currentArea.endPoint[0]) === KeepEight(currentPoint.cx()) &&
                    KeepEight(currentArea.endPoint[1]) === KeepEight(currentPoint.cy())
                ) {
                    self.$set(this.vm.currentDrawData, "endPoint", null);
                    self.$set(this.vm.currentDrawData, "endPointInd", -1);
                }
            } else if (type === "bottom") {
                self.$set(this.vm.currentDrawData, "endPoint", [
                    currentPoint.cx(),
                    currentPoint.cy()
                ]);
                self.$set(this.vm.currentDrawData, "endPointInd", pointInd);
                if (
                    currentArea.startPoint &&
                    KeepEight(currentArea.startPoint[0]) === KeepEight(currentPoint.cx()) &&
                    KeepEight(currentArea.startPoint[1]) === KeepEight(currentPoint.cy())
                ) {
                    self.$set(this.vm.currentDrawData, "startPoint", null);
                    self.$set(this.vm.currentDrawData, "startPointInd", -1);
                }
            } else if (type === "normal") {
                var currentX = currentPoint.cx(),
                    currentY = currentPoint.cy();
                if (
                    currentArea.startPoint &&
                    KeepEight(currentArea.startPoint[0]) === KeepEight(currentX) &&
                    KeepEight(currentArea.startPoint[1]) === KeepEight(currentY)
                ) {
                    self.$set(this.vm.currentDrawData, "startPoint", null);
                    self.$set(this.vm.currentDrawData, "startPointInd", -1);
                } else if (
                    currentArea.endPoint &&
                    KeepEight(currentArea.endPoint[0]) === KeepEight(currentX) &&
                    KeepEight(currentArea.endPoint[1]) === KeepEight(currentY)
                ) {
                    self.$set(this.vm.currentDrawData, "endPoint", null);
                    self.$set(this.vm.currentDrawData, "endPointInd", -1);
                }
            }
            // 变色
            $(".adjust-size").each(function(ind, item) {
                var cx = $(item).attr("cx"),
                    cy = $(item).attr("cy");
                $(item).css({
                    fill: "rgb(0, 162, 255)"
                });
                $(item).attr("point-type", ""); // dom上添加标记
                if (
                    currentArea.startPoint &&
                    KeepEight(currentArea.startPoint[0]) === KeepEight(cx) &&
                    KeepEight(currentArea.startPoint[1]) === KeepEight(cy)
                ) {
                    $(item).css({
                        fill: "red"
                    });
                    $(item).attr({
                        "point-type": "startPoint",
                        title: "上边界点"
                    }); // dom上添加标记
                }
                if (
                    currentArea.endPoint &&
                    KeepEight(currentArea.endPoint[0]) === KeepEight(cx) &&
                    KeepEight(currentArea.endPoint[1]) === KeepEight(cy)
                ) {
                    $(item).css({
                        fill: "green"
                    });
                    $(item).attr({
                        "point-type": "endPoint",
                        title: "下边界点"
                    }); // dom上添加标记
                }
            });
        },
        /**
         * 点击后的回调函数  新增
         * @param id
         */
        setClick: function(id, source, e) {
            // 点击事件
            if (this.vm.selectId != id && !source) {
                this.globalCloseUnfold();
            }
            if (!e || (e && e.button === 0)) {
                // 绘图完成successCallback是mousedown触发，successCallback回调中会触发setCLick；插件返回的click事件在mouseUp触发，会触发两次；
                this.poppupShow = false;
                this.pointPopupShow = false; // 关闭点标记弹窗
            }
            if (!!id && !source) {
                // 点击图形 对应列表项 滚动到可视区域显示
                this.$nextTick(function() {
                    var clickDom = document.getElementById(id + "_list");
                    clickDom && $(".content_right_two").animate({ scrollTop: clickDom.offsetTop - 200 },300);
                });
            }
            this.vm.selectId = id;
            // !source ? this.globalCloseUnfold() : '';
            var vmList = this.showList;
            for (var i = 0; i < vmList.length; i++) {
                if (vmList[i].id == id) {
                    self.$set(this.vm, "currentDrawData", vmList[i]); // 当前选择图形的信息对象
                    try {
                        self.graphicsMoveCallback();
                    } catch (e) {}
                    break;
                }
            }
            if (!this.checkboxsGroup.hierarchy && id != "defaultGroup") {
                // 继承层级开关 关闭时 才允许赋值
                this.hierarchyId = id;
            }
            svg.createDragPoint(id); // 图形被聚焦

            var currentArea = this.vm.currentDrawData;

            // 变色
            $(".adjust-size").each(function(ind, item) {
                var cx = $(item).attr("cx"),
                    cy = $(item).attr("cy");
                $(item).css({
                    fill: "rgb(0, 162, 255)"
                });
                $(item).attr("point-type", ""); // dom上添加标记
                if (currentArea.startPoint) {
                }
                if (
                    currentArea.startPoint &&
                    KeepEight(currentArea.startPoint[0]) === KeepEight(cx) &&
                    KeepEight(currentArea.startPoint[1]) === KeepEight(cy)
                ) {
                    $(item).css({
                        fill: "red"
                    });

                    $(item).attr({
                        "point-type": "startPoint",
                        title: "上边界点"
                    }); // dom上添加标记
                    self.$set(self.vm.currentDrawData, "startPointInd", $(item).attr("data-point-index"));
                }
                if (
                    currentArea.endPoint &&
                    KeepEight(currentArea.endPoint[0]) === KeepEight(cx) &&
                    KeepEight(currentArea.endPoint[1]) === KeepEight(cy)
                ) {
                    $(item).css({
                        fill: "green"
                    });
                    $(item).attr({
                        "point-type": "endPoint",
                        title: "下边界点"
                    }); // dom上添加标记
                    self.$set(self.vm.currentDrawData, "endPointInd", $(item).attr("data-point-index"));
                }
            });

            $("textarea").blur();
            svg.addHightlight(id);

            if (/^pl-\d+/g.test(id)) {
                SVG.get(id).addClass("no-fill");
                id = SVG.get(id).data("parent");
            }
            // 多边形事件绑定与销毁
            if (/^p-\d+/g.test(id)) {
                self.polygonBindEvent(id);
            }
        },
        // 多边形事件的销毁与绑定 新增
        polygonBindEvent: function(id) {
            id = id + "-group";
            var domElement = SVG.get(id);
            domElement.off("mousemove");
            domElement.off("mouseleave");
            domElement.on("mousemove", function() {
                svg.bindPolygon("mousemove");
            });
            domElement.on("mouseleave", function() {
                svg.bindPolygon("mouseleave");
            });
        },
        // 数据设置  domObject 图形对象 handleType 处理方式  新增 oId 新增  旧ID 矩形转多边形
        setDrawData: function(domObject, handleType, oId) {
            var id = domObject.id(),
                type = domObject.type,
                data = {};
            var attrType = $(domObject.node).attr("type"); // 获取继承的属性 只有开启继承 初始绘制完成才有默认属性
            if (type === "rect") {
                data = {
                    id: id,
                    region: "rect",
                    w: domObject.width(),
                    h: domObject.height(),
                    x: domObject.x(),
                    y: domObject.y(),
                    dom: domObject.node,
                    text: "",
                    alias: this.successNum + "",
                    type: attrType === undefined ? "" : attrType,
                    machineTxt: "",
                    markTxt: "",
                    checkTxt: "",
                    markModifyRate: this.base.step === 0 ? 100 : "--",
                    checkModifyRate: this.base.step === 1 ? 100 : "--",
                    qualityModifyRate: this.base.step === 2 ? 100 : "--"
                };

            } else if (type === "polygon") {
                data = {
                    id: domObject.id(),
                    text: "",
                    region: "area",
                    points: domObject.attr("points"),
                    dom: domObject.node,
                    type: attrType === undefined ? "" : attrType,
                    machineTxt: "",
                    markTxt: "",
                    checkTxt: "",
                    markModifyRate: this.base.step === 0 ? 100 : "--",
                    checkModifyRate: this.base.step === 1 ? 100 : "--",
                    qualityModifyRate: this.base.step === 2 ? 100 : "--"
                };
            } else if (type === "polyline") {
                // 折线不需要添加属性
                data = {
                    id: domObject.id(),
                    text: "",
                    region: "polyline",
                    pId: domObject.data("parent"),
                    points: domObject.attr("points"),
                    dom: domObject.node
                };
            }

            if (handleType === "add" && type === "polygon") {
                // jbc 修改
                var pointArr = data.points.split(" ");
                if (pointArr.length === 4) {
                    data.startPoint = pointArr[0].split(",");
                    data.startPointInd = 0;
                    data.endPoint = pointArr[2].split(",");
                    data.endPointInd = 2;
                }
                this.vm.list.push(data);
            } else if (handleType === "add" && type === "rect") {
                // jbc 修改
                data.startPoint = [data.x, data.y];
                data.startPointInd = 0;
                data.endPoint = [data.x + data.w, data.y + data.h];
                data.endPointInd = 3;

                this.vm.list.push(data);
            } else if (handleType === "change") {
                this.findDataFromArr(domObject.id(), this.vm.list, 1, data);
            } else if (handleType === "add" && type === "polyline") {
                this.findDataFromArr(domObject.data("parent"), this.vm.list, 2, data);
            } else if (handleType === "conversion") {
                this.findDataFromArr(oId, this.vm.list, 3, data);
            } else if (handleType === "push" && type === "polygon") {
                var pointArr = data.points.split(" ");
                if (pointArr.length === 4) {
                    data.startPoint = pointArr[0].split(",");
                    data.startPointInd = 0;
                    data.endPoint = pointArr[2].split(",");
                    data.endPointInd = 2;
                }
                this.findDataFromArr(this.hierarchyId, this.vm.list, 2, data);
            } else if (handleType === "push" && type === "rect") {
                // jbc 修改
                data.startPoint = [data.x, data.y];
                data.startPointInd = 0;
                data.endPoint = [data.x + data.w, data.y + data.h];
                data.endPointInd = 3;
                this.findDataFromArr(this.hierarchyId, this.vm.list, 2, data);
            }
            this.synchToFile();
        },
        // 图形修改后的回调  新增
        changeCallBack: function(domObject) {
            var id = domObject.id();
            self.setDrawData(domObject, "change");
        },
        // 从数组中查找数据 id 当前数据的id  data 目标源数据 isChange (1)是否修改 (2)是否添加为子元素 (3)是否是矩形转多边形  info 新数据  新增
        findDataFromArr: function(id, data, isChange, info) {
            for (var i = 0; i < data.length; i++) {
                if (data[i].children && data[i].children.length > 0) {
                    if (data[i].id === id) {
                        if (isChange === 1) {
                            if (data[i].region === "rect") {
                                data[i].w = info.w;
                                data[i].h = info.h;
                                data[i].x = info.x;
                                data[i].y = info.y;
                            } else {
                                data[i].points = info.points;
                            }
                        }
                        if (isChange === 2) {
                            // self.$set(data[i], 'children', data[i].children || [])
                            data[i].children = data[i].children || [];
                            data[i].children.push(info);
                        }

                        if (isChange === 3) {
                            delete data[i].w;
                            delete data[i].h;
                            delete data[i].x;
                            delete data[i].y;
                            data[i].id = info.id;
                            data[i].region = "area";
                            data[i].points = info.points;
                            data[i].dom = info.node;
                        }
                        return data[i];
                    }
                    this.findDataFromArr(id, data[i].children, isChange, info);
                } else {
                    if (data[i].id === id) {
                        if (isChange === 1) {
                            if (data[i].region === "rect") {
                                data[i].w = info.w;
                                data[i].h = info.h;
                                data[i].x = info.x;
                                data[i].y = info.y;
                            } else {
                                data[i].points = info.points;
                            }
                        }
                        if (isChange === 2) {
                            data[i].children = data[i].children || [];
                            data[i].children.push(info);
                        }

                        if (isChange === 3) {
                            delete data[i].w;
                            delete data[i].h;
                            delete data[i].x;
                            delete data[i].y;
                            data[i].id = info.id;
                            data[i].region = "area";
                            data[i].points = info.points;
                            data[i].dom = info.node;
                        }
                        return data[i];
                    }
                }
            }
        },
        //  数据同步  新增
        synchToFile: function(id) {
            var list = Object.assign([], [], this.vm.list);
            if (id) {
                this.files.current.result[id] = Object.assign(
                    this.files.current.result[id] ? this.files.current.result[id] : [],
                    this.vm.list[id]
                );
            }
            // this.files.current.result = Object.assign([] ,[], this.vm.list);
            self.$set(this.files.current, "result", list);
            this.vm.list = this.files.current.result;
        },
        /**
         * 图片预加载
         * @param img 图片地址
         */
        preLoading: function(img) {
            if (!img) {
                return false;
            }
            var oImg = new Image(),
                url = "";
            oImg.src = img;
            if (oImg.complete) {
                url = self.files.allImage.shift();
                //如果图片已经存在于浏览器缓存,直接调用回调函数
                self.preLoading(url);
            } else {
                oImg.onload = function() {
                    url = self.files.allImage.shift();
                    //如果图片已经存在于浏览器缓存,直接调用回调函数
                    self.preLoading(url);
                };
            }
        },
        // 选择属性
        selectTag: function(ename, cname) {
            var id = this.vm.selectId; // 当前选中的id;
            var itemReadOnly = self.readOnly.indexOf(ename) > -1; // bcjia修改
            if (this.history.showVersionInfo || this.history.show) {
                // 查看历史时 不能修改
                return false;
            }

            if (id === "" || id === "defaultGroup") {
                return false;
            }
            if (this.vm.currentDrawData.type === ename) {
                // 如果上一次的 标签和 这一次的标签相同 则取消 2018/9/29
                self.$set(this.vm.currentDrawData, "type", "");
            } else {
                // 否则给当前的属性 2018/9/29
                self.$set(this.vm.currentDrawData, "type", ename);
                if (!this.checkboxsGroup.inHeritAttr) {
                    // 二次公测时 修改 只有在开关关闭时 才设置继承的属性
                    this.copeAttrCnt = ename; // 继承属性 保留最后一次选择的属性值
                }
            }

            if (itemReadOnly) {
                // bcjia修改 代表是特殊属性
                self.$set(this.vm.currentDrawData, "text", "");
            }

            $(this.vm.currentDrawData.dom).attr("type", this.vm.currentDrawData.type); // 在dom存type 用直接取 避免遍历
            this.vm.preMarkInfo = ""; // name 设置一个默认前者的 标签 暂时的需求是 不需要继承 上一次的属性了 2018/9/29
            // this.synchCurrentData('type',name)
        },
        // 增加筛选条件 (有的话 去掉,没有添加)
        changeScreening: function(ename, cname) {
            var exist = this.interactive.screeningTag.indexOf(ename);
            if (exist === -1) {
                this.interactive.screeningTag.push(ename);
                // self.$set(this.interactive.screeningTag, this.interactive.screeningTag.length, item)
            } else {
                this.interactive.screeningTag.splice(exist, 1);
            }
            self.showPaintboxByTag(this.interactive.screeningTag);
        },
        // 筛选框关闭
        changeScreeningCls: function() {
            this.filterBoxShow = false;
            self.$set(this.interactive, "screeningTag", []);
            this.showPaintboxByTag(this.interactive.screeningTag);
        },
        // 根据属性 展示 绘图框
        showPaintboxByTag: function(tags) {
            var doms = SVG.select(".area-box");
            var point = SVG.select(".adjust-size").members[0]; // 拖拽点
            var pointParent = ""; // 拖拽点 所属 父亲
            if (point) {
                pointParent = SVG.select(".adjust-size").members[0].data("parent");
            }
            var list = this.vm.list;
            list.forEach(function(lists) {
                var id = lists.id;
                if (tags.length === 0) {
                    lists.isShow = true;
                    SVG.get(id + "-group") && SVG.get(id + "-group").attr("display", "block");
                    return;
                }
                if (tags.indexOf(lists.type) == -1) {
                    SVG.get(id + "-group") && SVG.get(id + "-group").attr("display", "none")
                    lists.isShow = false;
                    if (id === pointParent) {
                        // 如果当前元素 隐藏 是其点也相对隐藏
                        self.hidePoint(true);
                    }
                } else {
                    SVG.get(id + "-group") && SVG.get(id + "-group").attr("display", "block")
                    lists.isShow = true;
                    if (id === pointParent) {
                        // 如果当前元素 隐藏 是其点也相对隐藏
                        self.hidePoint(false);
                    }
                }
            });
        },
        // 隐藏点
        hidePoint: function(isHide) {
            var adjustSize = SVG.select(".adjust-size");
            adjustSize.each(function() {
                if (isHide) {
                    this.hide();
                } else {
                    this.show();
                }
            });
        },
        // 拖拽区域滚动事件
        scroll: function(e) {
            var outBoxH = $(".content_right_two").height();
            var targetH = $(this.$refs["lebals"]).height();
            var topVal = !this.arrowShow ? 100 : 50;
            if (!this.drapSrlDom) return; // 没有选中拖拽目标
            var eTop = this.drapSrlDom.getBoundingClientRect().top;
            if (targetH + eTop - topVal > outBoxH) {
                $(this.$refs["lebals"]).css({
                    bottom: "30px",
                    top: "auto"
                });
            } else if (eTop - topVal < 0) {
                $(this.$refs["lebals"]).css({
                    bottom: "auto",
                    top: "2px"
                });
            } else {
                $(this.$refs["lebals"]).css({
                    bottom: "auto",
                    top: eTop - topVal + "px"
                });
            }
        },
        // 选择属性
        selAttrFn: function(e, ind, item) {
            this.vm.type = "click";
            self.$set(this.vm, "currentDrawData", item); // 当前选择图形的信息对象
            this.cursorLocation = item.text.length;
            if (!item.unfold) {
                this.preListsObj && (this.preListsObj.unfold = false);
                this.preListsObj = item;
            }
            // console.log(this.vm.list)
            this.$nextTick(function() {
                var outBoxH = $(".content_right_two").height();
                this.drapSrlDom = this.$refs["srl" + ind][0];
                var targetH = $(this.$refs["srl" + ind][0]).height();
                // console.log($(this.$refs['srl'+ind][0]).height())
                var topVal = !this.arrowShow ? 100 : 50;
                var eTop = this.drapSrlDom.getBoundingClientRect().top;
                if (targetH + eTop - topVal > outBoxH) {
                    $(this.$refs["lebals"]).css({
                        bottom: "30px",
                        top: "auto"
                    });
                } else {
                    $(this.$refs["lebals"]).css({
                        bottom: "auto",
                        top: eTop - topVal + "px"
                    });
                }
                item.unfold = !item.unfold;
                if (item.region == "polyline") {
                    this.lebalLebals = false;
                } else {
                    this.lebalLebals = item.unfold;
                    if (this.lebalLebals) {
                        $(".lebal-lebals").scrollTop(0);
                    }
                }
            });
            this.setClick(item.id, "fromList");
            if (!this.history.showVersionInfo) {
                // 查看历史时，不能修改
                // this.controllShow(item.id, 0)
            }
        },
        // 删除选中的图形
        delectSelectBox: function(kj) {
            var _Vue = this;
            this.poppupShow = false; // 快速编辑框 关闭
            var delObj = []; // 保存嵌套删除的对象
            if (this.history.showVersionInfo || this.history.show) {
                // 如果查看历史不准删除
                _Vue.ableKey = true;
                return false;
            }
            var id = this.vm.selectId; // 当前选中的矩形
            var status = false;
            this.lebalLebals = false; // 关掉打属性框
            if (id === "defaultGroup" || !id) {
                // 如果当前id不是绘图框
                if (!kj) {
                    self.ui.fade("当前尚未选择图形");
                }
                _Vue.ableKey = true;
                /*setTimeout(function () {
                            _Vue.ableKey = true;
                        },1000);*/
            } else {
                var tsTxt = "是否删除当前选中的图形",
                    yTxt = "确定",
                    nTxt = "取消";
                // children中是否存在折线
                var hasPolyline = self.vm.currentDrawData.children && self.vm.currentDrawData.children[0] 
                            ? self.vm.currentDrawData.children.some(function(item) {
                                return item.region == "polyline";
                            })
                            : "";
                if (!hasPolyline && hasPolyline === false) {
                    // 不存在折线
                    tsTxt = "是否同时删除嵌套图形";
                    (yTxt = "只删除选中图形"), (nTxt = "同时删除所有嵌套图形");
                }
                if (hasPolyline) {
                    // 存在折线
                    tsTxt = "是否删除选中多边形及所有折线";
                    (yTxt = "删除"), (nTxt = "只删除第一条折线");
                }
                // 提示框
                self.ui.dialogs("操作提醒", tsTxt, yTxt, nTxt).then(function(){
                    // 删除当前元素
                    try {
                        // delete _Vue.vm.list[id]; // 删除
                        var list = _Vue.vm.list;
                        if (!!hasPolyline) {
                            delListItem(list, false); // 内部有折线默认全删除
                        } else {
                            delListItem(list, true);
                        }
                        svg.clearDrawPoint(); // 清空 拖拽点
                        SVG.get(id).remove(); // 清空图形
                        SVG.get(id + "-text").remove(); // 删除文字
                        SVG.get(id + "-group") && SVG.get(id + "-group").remove(); // 清空父容器 折线么有group
                        _Vue.vm.selectId = ""; // 删除过后 应该将当前选中的id 清空
                        _Vue.ableKey = true;
                        self.$set(_Vue.vm, "currentDrawData", {});
                    } catch (e) {
                        // console.log(e)
                        self.ui.fade("当前尚未选择图形");
                        _Vue.ableKey = true;
                    }
                    self.closeSignPopup();
                }).catch(action => {
                    if(action === 'close') return; // 点击叉关闭弹框 不执行关闭逻辑
                    if (tsTxt == "是否同时删除嵌套图形") {
                        try {
                            // delete _Vue.vm.list[id]; // 删除
                            var list = _Vue.vm.list;
                            svg.clearDrawPoint(); // 清空 拖拽点
                            SVG.get(id).remove(); // 清空图形
                            SVG.get(id + "-text").remove(); // 删除文字
                            SVG.get(id + "-group") && SVG.get(id + "-group").remove(); // 清空父容器 折线么有group
                            delListItem(list, false);
                            _Vue.vm.selectId = ""; // 删除过后 应该将当前选中的id 清空
                            _Vue.ableKey = true;
                            self.$set(_Vue.vm, "currentDrawData", {});
                        } catch (e) {
                            console.log(e);
                            self.ui.fade("当前尚未选择图形");
                            _Vue.ableKey = true;
                        }
                    }
                    if (tsTxt == "是否删除选中多边形及所有折线") {
                        try {
                            // delete _Vue.vm.list[id]; // 删除
                            var list = _Vue.vm.list;
                            // svg.clearDrawPoint(); // 清空 拖拽点
                            // SVG.get(id).remove(); // 清空图形
                            // SVG.get(id + '-text').remove(); // 删除文字
                            // SVG.get(id + '-group') ? SVG.get(id + '-group').remove() : ''; // 清空父容器 折线么有group
                            delListItem(list, false, true);
                            // _Vue.vm.selectId = ''; // 删除过后 应该将当前选中的id 清空
                            _Vue.ableKey = true;
                            // self.$set(_Vue.vm, 'currentDrawData', {});
                        } catch (e) {
                            console.log(e);
                            self.ui.fade("当前尚未选择图形");
                            _Vue.ableKey = true;
                        }
                    }
                    _Vue.ableKey = true;
                })

                // 递归删除图形方法
                /**
                 *  isYes false 同时删除所有子元素 true 只删除自己
                 *  delFirst true 删除第一条折线
                 */
                function delListItem(list, isYes, delFirst) {
                    for (var i = 0; i < list.length; i++) {
                        if (list[i].id == id) {
                            var childrenArr = list[i].children;
                            if (!!delFirst) {
                                for (var i = 0; i < childrenArr.length; i++) {
                                    if (childrenArr[i].isFirst) {
                                        self.$nextTick(function() {
                                            SVG.get(childrenArr[i].id).remove(); // 清空图形
                                            SVG.get(childrenArr[i] + "-text") && SVG.get(childrenArr[i] + "-text").remove(); // 删除文字
                                            childrenArr.splice(i, 1);
                                            var newFirstLine = self.setLine(id, list);
                                            // 是否需要关闭继承层级开关
                                            if (newFirstLine && self.hierarchyId === newFirstLine.id) {
                                                self.checkboxsGroup.hierarchy = false;
                                            }
                                            // 新的第一条折线 要判断内部是否存在子元素 有的全删
                                            if (newFirstLine && (newFirstLine.children && newFirstLine.children[0])) {
                                                removeDom(newFirstLine.children);
                                                newFirstLine.children = [];
                                            }
                                        });
                                        break;
                                    }
                                }
                                return self.refresh++; // 触发更新
                            }
                            var oldPid = list[i].pId;
                            list.splice(i, 1); // 当前这一项 删除
                            if (childrenArr && childrenArr[0]) {
                                if (!isYes) {
                                    removeDom(childrenArr);
                                } else {
                                    for (var j = childrenArr.length - 1; j >= 0; j--) {
                                        childrenArr[j].pId = oldPid; // 删除父级 重置原来子级的pId
                                        list.splice(i, 0, childrenArr[j]);
                                    } // 子元素插进来
                                }
                            }
                            self.refresh++; // 触发更新
                            return false;
                        }
                        // console.log(list)
                        if (list[i].children && list[i].children[0]) {
                            var children = list[i].children;
                            if (delListItem(children, isYes, delFirst) === false)
                            return false;
                        }
                    }
                }
                // 递归删除dom节点
                function removeDom(lists) {
                    lists.forEach(function(item) {
                        SVG.get(item.id) && SVG.get(item.id).remove(); // 清空图形
                        SVG.get(item.id + "-text") && SVG.get(item.id + "-text").remove(); // 删除文字
                        SVG.get(item.id + "-group") && SVG.get(item.id + "-group").remove(); // 清空父容器 折线么有group
                        if (item.children && item.children[0]) {
                            removeDom(item.children);
                        }
                    });
                }
            }
        },
        // 绘图按钮 type: number 1 矩形 2 多边形 3 折线 （需要选中多边形）4 筛选 5 未知  6 拖拽
        sendclickType: function(type, zxType) {
            var self = this;
            this.poppupShow = false; // 快速编辑框 关闭
            if (this.history.showVersionInfo || this.history.show) return;
            if (this.files.current.isBad == 1) {
                return self.ui.fade("当前数据为坏数据，不允许进行绘制！");
            }

            // 继承层级条件过滤
            if (this.checkboxsGroup.hierarchy) {
                if (this.hierarchyId === "") {
                    // 首先 得有继承的层级图形
                    return self.ui.fade("继承层级功能已开启,未选择需要继承的层级！");
                }
                var vmList = this.showList; // 其次 选择的继承层级图形 还存在 (可能操作中间被删除)
                var hierarchyDom = null;
                if (!vmList.some(function(item) {
                        if (item.id === self.hierarchyId) {
                            hierarchyDom = item;
                        }
                        return item.id === self.hierarchyId;
                    })
                ) {
                    return self.ui.fade("继承层级图形不存在");
                }
                if (!hierarchyDom.alias && hierarchyDom.isFirst) {
                    // 第一条折线
                    this.checkboxsGroup.hierarchy = false;
                    return self.ui.fade("当前父层级为多边形内第一条折线，不允许被继承！");
                }
                if (hierarchyDom.alias.split("-").length >= 4) {
                    // 继承的图形层级不能为四层
                    return self.ui.fade("最多嵌套4层,请重新选择继承层级图形");
                }
            }

            var drawType = "click";
            var dataType = typeof type;
            if (type == 5) {
                // 语义引擎操作
                return this.getOverallConversion(zxType);
            }
            if (dataType === "number") {
                if (type === 1) {
                    drawType = "rect";
                } else if (type === 2) {
                    drawType = "polygon";
                } else if (type === 3) {
                    // 开启继承层级按钮时
                    if (this.checkboxsGroup.hierarchy && !/^p-\d+/g.test(this.hierarchyId)) {
                        self.ui.fade("折线只允许是多边形的子级,请重新选择继承层级");
                        svg.cancelDraw(); // 取消正在绘制
                        svg.initCursor(); // 初始化光标
                        self.drawOver = true;
                        self.vm.type = "click"; // 初始化绘制类型
                        self.lastType = "click"; // 初始化上次绘制类型
                        return;
                    }
                    // 没有开启继承层级时 需要点击聚焦多边形
                    if (!this.checkboxsGroup.hierarchy && !/^p-\d+/g.test(this.vm.selectId)) {
                        self.ui.fade("请选择多边形");
                        svg.cancelDraw(); // 取消正在绘制
                        svg.initCursor(); // 初始化光标
                        self.drawOver = true;
                        self.vm.type = "click"; // 初始化绘制类型
                        self.lastType = "click"; // 初始化上次绘制类型
                        return;
                    } else if (this.checkboxsGroup.hierarchy) {
                        // this.vm.selectId = this.hierarchyId;
                        this.setClick(this.hierarchyId);
                    }
                    drawType = "polyline";
                } else if (type === 6) {
                    // 拖拽
                    drawType = "drag";
                }
            } else if (dataType === "string") {
                // 字符串 直接赋值
                if (type === "polyline") {
                    if (!/^p-\d+/g.test(this.vm.selectId)) {
                        self.ui.fade("请选择多边形");
                        return;
                    }
                }
                drawType = type;
            }

            if (drawType !== "drag") {
                // 如果不是拖拽 就记录
                this.lastType = drawType;
            }
            if (
                (drawType === "drag" || dataType === "rect" || dataType === "polygon" || dataType === "polyline") 
                && drawType !== this.vm.type && svg.dm.currentDraw) {
                svg.externalCheck();
            }

            if (this.vm.type && drawType !== this.vm.type) {
                svg.externalCheck(); // 校验当前图形是否符合规则
            }

            this.vm.type = drawType;

            // 设置光标
            if (this.vm.type === "polyline") {
                svg.setCursor();
            }
        },
        // 初始化后套返回扁平数据转换树状结构
        flatToTreeData: function(lists) {
            var tempMap = {};
            lists ? lists : (lists = []); // 返回的值 是否存在
            for (var i = 0, len = lists.length; i < len; i++) {
                var item = lists[i];
                item.parent = null;
                item.children = [];
                tempMap[item.id] = item;
                // 2019/3/21 新需求 兼容云盘导入的默认属性
                if (item.type && self.checkType[item.type] === undefined) {
                    self.$set(self.checkType, item.type, item.type);
                }
            }
            var newArr = [];
            for (var i = 0, len = lists.length; i < len; i++) {
                var item = lists[i];
                if (item.pId != -1 && item.pId != undefined) {
                    var parent = tempMap[item.pId];
                    if (parent) {
                        // 有可能被删了 但pId可能没被修改
                        parent.children.push(item);
                    } else {
                        var aliasArr = item.alias.split("-"),
                            aliasLen = aliasArr.length,
                            aliasStr = "";
                        if (aliasLen > 1) {
                            aliasArr.pop();
                            aliasStr = aliasArr.join("-");
                            var isHas = false;
                            for (var k in tempMap) {
                                if (tempMap[k].alias === aliasStr) {
                                    // 存在alias相同
                                    tempMap[k].children.push(item);
                                    isHas = true;
                                    break;
                                }
                            }
                            if (!isHas) {
                                // 不存在alias相同
                                item.pId = -1;
                                newArr.push(item);
                            }
                        } else {
                            // 自身就在第一层 但存在pId
                            item.pId = -1;
                            newArr.push(item);
                        }
                    }
                } else {
                    newArr.push(item);
                }
            }
            return newArr;
        },
        // 树状数据转扁平 供保存使用
        treeToFlatData: function(lists) {
            var info = [];
            setRightList(lists, info);

            function setRightList(data, info, itemPrt) {
                data.forEach(function(item, index) {
                    info.push({
                        alias: item.alias,
                        cid: item.cid,
                        id: item.id,
                        pointnum: item.pointnum,
                        points: item.points,
                        region: item.region,
                        startPoint: item.startPoint,
                        startPointInd: item.startPointInd,
                        endPointInd: item.endPointInd,
                        endPoint: item.endPoint,
                        text: item.text,
                        type: item.type,
                        pId: item.parent
                            ? itemPrt.id
                            : item.pId === undefined ? -1 : item.pId,
                        isFirst: item.isFirst,
                        x: item.x,
                        y: item.y,
                        w: item.w,
                        h: item.h,
                        machineTxt: !!item.machineTxt ? item.machineTxt : "",
                        markTxt:
                            self.base.step === 0
                                ? item.text
                                : item.markTxt ? item.markTxt : "",
                        checkTxt:
                            self.base.step === 1
                                ? item.text
                                : item.checkTxt ? item.checkTxt : "",
                        markModifyRate: item.markModifyRate,
                        checkModifyRate: item.checkModifyRate,
                        qualityModifyRate: item.qualityModifyRate,
                        markAverageRate: item.markAverageRate,
                        checkAverageRate: item.checkAverageRate,
                        qualityAverageRate: item.qualityAverageRate
                    });
                    if (item.children && item.children[0]) {
                        setRightList(item.children, info, item);
                    }
                });
            }
            return info;
        },
        // 修改当前绘制状态(同时隐藏十字光标)
        changeType: function(type) {
            // 坏数据不允许进行绘制
            if (this.files.current.isBad == 1) {
                return self.ui.fade("当前数据为坏数据，不允许进行绘制！");
            }
            // 先做一次校验 , 查看历史不能切换 绘图状态
            if (
                (this.history.showVersionInfo || this.history.show) &&
                (type === "rect" || type === "polygon")
            ) {
                return false;
            }

            this.vm.type = type;

            if (type !== "drag") {
                // 如果不是拖拽 就记录
                this.lastType = type;
            }
            if (type === "drag") {
                svg.initCursor(); // 初始化光标
            }
        },
        async showHistory () {
            var self = this;
            this.closeSignPopup();
            if (!self.getFile().result) {
                return self.ui.error("无任务");
            }
            this.history.list = [];
            var fileId = self.getFile().id;
            await this.ass_api.getHistoryList(self.taskId, self.markTaskId, fileId).then((info) => {
                if(!info) return;
                var len = info.length;
                for (var i = 0; i < len; i++) {
                    self.history.list.unshift(info[i]);
                }
            })
            self.history.show = true;
            self.setClick("svgImage");
        },
        getSelectClass: function(_type) {
            if (_type == this.files.showType) {
                return "selected";
            }
        },
        /**
         *  选择区域数据
         * @param _type
         * @param lastIndex
         */
        selectData: function(_type, lastIndex) {
            // 选择对应的数据
            if (!!!this.dataLength[_type - 1]) return;
            if (!self.interactive.currentFinished && _type !== 1) {
                // 切换需要做限制
                this.ui.fade("当前图片尚未加载完毕");
                return false;
            }
            if (isNaN(Number(lastIndex))) {
                // 如果 lastIndex 无非转换成数字 默认0
                lastIndex = 0;
            }
            this.poppupShow = false; // 快速编辑框 关闭

            self.files.showType = _type;
            var len = self.files.allInfo.length,
                showList = [];

            if (_type === 1) {
                // 全部数据
                showList = self.files.allInfo;
            } else {
                for (var i = 0; i < len; i++) {
                    var item = self.files.allInfo[i];
                    if (item.isBad === 0 && _type === 2) {
                        // 好数据
                        // console.log(2)
                        showList.push(item);
                    } else if (item.isBad === 1 && _type === 3) {
                        // 坏数据
                        // console.log(3)
                        showList.push(item);
                    } else if (item.status === 0 && _type === 4) {
                        // 未标注
                        // console.log(4)
                        showList.push(item);
                    }
                }
            }
            var len2 = showList.length;
            for (var i = 0; i < len2; i++) {
                var file = showList[i];
                file.last = i == 0 ? null : showList[i - 1];
                file.next = i == len - 1 ? null : showList[i + 1];
            }
            self.files.showList = showList; // 给当前列表赋值

            self.selectFile(self.files.showList[lastIndex]);
        },
        /**
         * 选择单个文件
         * @param item 当前条的数据
         */
        selectFile: function(item) {
            var self = this;
            if (self.Utils.isNull(item)) {
                self.initAboutImgData(true); // 初始化所有和图片相关的信息
                self.vm.imgData.imgPath = "";
                self.files.curIndex = -1;
                self.$set(self.files, "current", {});
                return false;
            } // 如果空 返回
            // if(item.isLoad === undefined){ // 没有校验图片合法
            this.checkImg(item, function() {
                sltInFn();
            });
            // return;
            // }
            // sltInFn();
            function sltInFn() {
                self.initAboutImgData(true); // 初始化所有和图片相关的信息
                self.vm.imgData.imgPath = item.url;
                self.files.curIndex = item.id;
                // 这里先赋值 数据
                self.$set(self.files, "current", item);
                if (!item.isLoad) {
                    // 没有校验图片合法
                    self.ui.dialogs('操作提醒', 
                        '<div style="text-align:center;padding: 24px 0;font-size:18px">当前图片加载失败</div>',
                        {
                            confirmButtonText: '重新加载',
                            cancelButtonText: '数据标坏',
                            type: 'warning'   
                    }).then(() => {
                        self.selectFile(item);
                    }).catch(async action => {
                        if(action === 'close') return;
                        if (!item.isInit) {
                            // 如果第一次直接获取结果服务
                            await self.getCurResult(item);
                            self.calculateModificationRate(item.result); // 计算修改率
                        }
                        self.markBadData("", true);
                        self.interactive.currentFinished = true; // 初始化 可以不用写
                    })

                    return;
                }

                self.initFile(item);
            }
        },
        // 检查图片是否可用
        checkImg: function(item, cb) {
            var img = new Image();
            img.onload = function() {
                item.isLoad = true;
                cb();
            };
            img.onerror = function() {
                item.isLoad = false;
                cb();
            };
            img.src = item.url;
        },
        /**
         * 初始化单个文件
         * @param item
         */
        async initFile (item) {
            // if(!item.isLoad){
            //     self.interactive.currentFinished = true; // 初始化
            //     return; // 图片不合法退出
            // }
            // 判断是否获取最新结果 并初当前加载参数
            self.interactive.currentFinished = false; // 初始化
            self.interactive.screeningTag = []; // 初始化选中标签
            self.interactive.screeningShow = false; // 默认不展示
            if (!item.isInit) {
                // 如果第一次直接获取结果服务
                await self.getCurResult(item);
                self.calculateModificationRate(item.result); // 计算修改率
                svg = new OcrPublicClass(this.$data.vm); // 实例化图形
            } else {
                // 否则直接用当前文件
                svg = new OcrPublicClass(this.$data.vm); // 实例化图形
            }
        },
        /**
         * 从结果服务中获取是否存在新的结果
         * @param file
         */
     async getCurResult(file) {
            if (file.isInit === 1) return false; // 如果文件 isInit为 1 说明页面刷新后已经从结果拉去过一次
            // 表示需要获取最新的标注数据
            const getCurrentResult = this.ass_api.getCurrentResult(self.taskId, self.markTaskId, file.id);            
            await getCurrentResult.then(info => {
                if(!info) return;
                var curInfo = JSON.parse(info.resultText);
                var extend = info.extend;
                var curInfo = self.flatToTreeData(curInfo);
                curInfo ? curInfo.forEach(function(item) {
                            if (item.markAverageRate === undefined) {
                                item.markAverageRate = "--";
                            }
                            if (item.checkAverageRate === undefined) {
                                item.checkAverageRate = "--";
                            }
                            if (item.qualityAverageRate === undefined) {
                                item.qualityAverageRate = "--";
                            }
                        }) : "";

                curInfo[0] && (file.averageRate1 = curInfo[0].markAverageRate)
                curInfo[0] && (file.averageRate2 = curInfo[0].checkAverageRate)
                curInfo[0] && (file.averageRate3 = curInfo[0].qualityAverageRate)

                file.result = curInfo;
                file.isBad = info.extend.stamp;
                file.isInit = 1;
                file.lastSubmit = {
                    result: "", // JSON.stringify(self.arrToObject(file.result, false)),
                    isLastAuto: info.autoSave
                };
            })
        },
        /**
         * 跳转到某一条数据
         * @param item 数据
         * @param force 是否强制跳转 ，如果true 则可以跳到未标注的数据上
         * @returns {boolean}
         */
        skipFile: function(item, force) {
            if (item.status === 0 && !force) {
                this.ui.fade("不能跳转到未标注数据");
                return false;
            }
            if (item.id !== self.files.curIndex) {
                const savePromise = self.saveResult(false); 
                if (!savePromise) return;
                // self.saveResult(false)
                self.selectFile(item);
            }
        },
        /**
         * 图片加载成功后的回调  新增
         */
        imgLoadCallBack: function() {
            // 这里关联了 current 和 list
            var svgOutDomW = $("#drawing").width(),
                svgOutDomH = $("#drawing").height();
            var imgData = self.vm.imgData;
            var rate = 1;
            if (imgData.width > imgData.height) {
                rate = (imgData.width / svgOutDomW).toFixed(2) * 2;
            } else {
                rate = (imgData.height / svgOutDomH).toFixed(2);
            }
            self.vm.textSize = rate > 1 ? rate * 14 : 14;
            self.interactive.currentFinished = true; // 图形加载完毕
            self.dataConversion(self.files.current.result, true, true); // 这个current.result 可以是开始给的数组 也可能是标注过程中使用的对象;
            // 初始化 给每个图形dom绑定type 供筛选使用
            this.vm.list.forEach(function(lists) {
                $(SVG.get(lists.id).node).attr("type", lists.type);
                lists.isShow = true;
            });
            // 初始化不显示第一条折线
            var resultArr = self.files.current.result;

            self.firstLineInit(resultArr); // 初始化隐藏第一天折线
        },
        firstLineInit: function(data) {
            if (Object.prototype.toString.call(data) === "[object Array]") {
                for (var i = 0; i < data.length; i++) {
                    if (data[i].region === "area" && data[i].children && data[i].children[0]) {
                        // 找列表中存在的多边形
                        self.setLine(data[i].id, data);
                    }
                    if (data[i].children && data[i].children[0]) {
                        self.firstLineInit(data[i].children);
                    }
                }
            }
        },
        /**
         * 初始化和图片相关的参数
         * ①销毁svg实例 ②初始化相关参数 destroy 为true 代表全部销毁 false 代表只初始化参数
         */
        initAboutImgData: function(destroy) {
            if (destroy) {
                svg = null; // 销毁svg实例 并且将整个svg 销毁
                try {
                    SVG.get("#_drawing").remove();
                } catch (e) {}
            }
            this.vm = {
                // SVG 绘图相关的属性
                el: "drawing", // SVG 挂载点
                height: "100%", // SVG 渲染高度
                width: "100%", // SVG 渲染宽度
                type: "click", // 当前绘图的类型
                currentDrawData: {}, // 当前绘制图形的属性值
                currentId: 0, // 当前标注的文件序列 唯一不重复即可
                selectId: "", // 当前选中的 SVG 图像的id  主要为了获取当前选择的图形id
                maxId: 0, //当前图形中最大的Id
                list: [], // 图形数据 由于层级关系 需要用到
                isDisableRightKey: true, // 是否禁用右键
                zoom: 1, // 缩放比例
                maxZoom: 15, // 最大缩放比例
                minZoom: 0.02, // 最小缩放比例
                strokeWidth: 2, // 生成线的大小
                dragPointSize: 10, // 拖拽点的 大小
                textSize: 12, // 文本默认大小
                rotateDeg: 1, // 0 0, 1 90, 2 180 , 3  270,
                leaveEnd: false, // 是否离开使用
                imgData: {
                    // 图片的基本信息
                    imgPath:
                        "http://ainote.iflytek.com/static/images/reg_bg.jpg", // http://127.0.0.1:8081/static/img/test.3036edb.jpg
                    width: 0,
                    height: 0,
                    x: 0,
                    y: 0
                },
                canChooseP: true, //是否开启选中多边形呢的折线
                svgHightLightClass: "svg-highlight", // 高亮的calss
                currentPolyLineId: "", // 当前折线的id
                clickCallBack: this.setClick, // 点击的回掉函数
                successCallBack: this.successCallBack, // 绘图结束后的回掉
                drawFailCallBack: this.drawFailCallBack, // 绘制失败回调
                imgLoadCallBack: this.imgLoadCallBack, // svg img绘图成功后的回调
                changeCallBack: this.changeCallBack, // 图形修改后的回调
                pointMouseDown: this.pointCallBack,
                svgNodeClickCallBack: this.svgNodeClickCallBack, // svg单击回调函数
                svgNodeDblclickCallBack: this.svgNodeDblclickCallBack, // svg双击回调函数
                pointContextmenuCallback: this.pointContextmenuCallback, // 点右击事件
                dragPointMoveCallback: this.dragPointMoveCallback, // 拖拽点移动回调
                graphicsMoveCallback: this.graphicsMoveCallback // 图形移动回调
            };
        },
        // 数据转换  新增  isFirst 是否是第一层层
        dataConversion: function(list, isDraw, isFirst) {
            var data = [],
                maxId = 0,
                numId = "";
            var type = Object.prototype.toString.call(list);
            if (type === "[object Array]") {
                for (var i = 0; i < list.length; i++) {
                    var region = list[i].region; // 图形类型
                    var id = list[i].id; // 当前图形的id
                    var pId = list[i].pId; // 当前图形的pId
                    if (region === "rect") {
                        list[i].id = typeof id === "number" ? "r-" + id : id.indexOf("r-") === -1 ? "r-" + id : id; // 取最大的数
                    } else if (region === "area") {
                        list[i].id = typeof id === "number" ? "p-" + id : id.indexOf("p-") === -1 ? "p-" + id : id; // 取最大的数
                        list[i].points = this.polygonToNeed(list[i].points); // 多边形 point s 转换
                    } else if (region === "polyline") {
                        list[i].id = typeof id === "number" ? "pl-" + id : id.indexOf("pl-") === -1 ? "pl-" + id : id; // 取最大的数
                        list[i].points = this.polygonToNeed(list[i].points); // 多边形 point s 转换
                        list[i].pId =  typeof pId === "number" ? "p-" + pId : pId.indexOf("p-") === -1 ? "p-" + pId : pId; // 取最大的数
                    }

                    if (typeof id !== "number") {
                        // id 不是数字的是否
                        numId = id.match(/\d+/g);
                        if (numId) {
                            // 存在数字
                            id = Number(numId[0]);
                            if (isNaN(id)) {
                                id = i;
                            }
                        } else {
                            // 不存在数字
                            id = i;
                        }
                    }

                    if (id > self.vm.maxId) {
                        self.vm.maxId = id;
                    }

                    if (isFirst) {
                        data.push(list[i]);
                    }

                    if (list[i].children && list[i].children.length > 0) {
                        self.dataConversion(list[i].children, isDraw, false);
                    }
                }
                this.vm.currentId = Number(self.vm.maxId + 1); // 赋值最大的id
            } else {
                for (var j in list) {
                    // 只是用来计算最大的id
                    var id = list[j].id; // 获取当前的id
                    if (typeof id !== "number") {
                        // id 不是数字的是否
                        numId = id.match(/\d+/g);
                        if (numId) {
                            // 存在数字
                            id = Number(numId[0]);
                            if (isNaN(id)) {
                                id = i;
                            }
                        } else {
                            // 不存在数字
                            id = i;
                        }
                    }

                    if (id > self.vm.maxId) {
                        self.vm.maxId = id;
                    }
                }
                this.vm.currentId = Number(self.vm.maxId + 1); // 赋值最大的id
                data = list;
            }

            this.vm.list = data; // 整体赋值
            this.synchToFile(); // 同步 current 和 list
            if (isDraw) {
                this.drawByList(this.vm.list); // 绘制图形
            } else {
                return data;
            }
        },
        polygonToNeed: function(points) {
            var pointsData = [];
            var type = typeof points;

            if (type === "object") {
                for (var i = 0, len = points.length; i < len; i++) {
                    pointsData.push(points[i]);
                }
            } else if (type === "string") {
                points
                    .replace(/\(|\)/g, "")
                    .replace(/ /g, ";")
                    .split(";")
                    .filter(function(item) {
                        if (item.indexOf(",") > 0) {
                            var num = item.split(",");
                            for (var i = 0; i < num.length; i++) {
                                num[i] = Number(num[i]);
                            }
                            pointsData.push(num);
                        }
                    });
            }
            return pointsData;
        },
        // 根据数据绘制图形  新增
        drawByList: function(data) {
            svg.drawByListData(data);
        },
        // 下一条
        next: function() {
            if (this.history.showVersionInfo || this.history.show) return;
            this.closeSignPopup();
            var file = self.getFile();
            if (self.Utils.isNull(file.next)) {
                self.ui.fade("已是最后一条");
                return false;
            }
            const savePromise = self.saveResult(false); 
            if (savePromise) {
                // 下一条触发保存 自动异步
                self.selectFile(file.next);
                self.preListsObj && (self.preListsObj.unfold = false);
                self.lebalLebals = false;
            }
        },
        // 上一条
        pre: function() {
            // 暂时不触发保存
            if (this.history.showVersionInfo || this.history.show) return;
            this.closeSignPopup();
            var file = self.getFile();
            if (self.Utils.isNull(file.last)) {
                self.ui.fade("已是第一条");
                return false;
            }
            const savePromise = self.saveResult(false); 

            if (savePromise) {
                // 上一条触发保存 自动异步
                self.selectFile(file.last);
                self.preListsObj ? (self.preListsObj.unfold = false) : "";
                self.lebalLebals = false;
            }

            // self.selectFile(file.last);
        },
        // 获取某个文件
        getFile: function(_fileIndex) {
            if (_fileIndex === undefined) {
                return self.files.current;
            }
            var len = self.files.showList.length;
            for (var i = 0; i < len; i++) {
                var item = self.files.showList[i];
                if (item.index == _fileIndex) {
                    self.selectFile(item);
                    return item;
                }
            }
            return null;
        },
        // 主要用来调用保存方法
       async save () {
            const savePromise = self.saveResult(false);
            savePromise && await savePromise.then(() => {
            }).catch(err => {
                // ass_api.error(err, self.base.step);
            })
        },
        saveCheckData(isAuto){
            var file = self.getFile();
            // isOk = false; // 返回值，通知是否可用继续执行
            if (!file.result) {
                if (isAuto) {   
                    return; // 没有结果
                } else {
                    self.ui.fade("没有可保存任务")
                    return;
                }
            }
            var flatData = self.treeToFlatData(file.result);
            // 多边形提交 点的格式字符串转成数组
            flatData.forEach(function(item) {
                if (item.region == "area") {
                    item.points = self.polygonToNeed(item.points);
                } else if (item.region == "polyline") {
                    if (typeof item.points != "object" && typeof item.points == "string") {
                        // 折线point格式 保存时 再过滤一遍 确保保存的是[ [0,0] , [1,2] ]数组的格式
                        item.points = self.polygonToNeed(item.points);
                    }
                }
                if (self.base.step === 0) {
                    item.markAverageRate = self.markAverageRate; // 标注平均修改率
                } else if (self.base.step === 1) {
                    item.checkAverageRate = self.checkAverageRate; // 检查平均修改率
                    item.markAverageRate = file.averageRate1;
                } else if (self.base.step === 2) {
                    item.qualityAverageRate = self.qualityAverageRate; // 检查平均修改率
                    item.markAverageRate = file.averageRate1;
                    item.checkAverageRate = file.averageRate2;
                }
            });

            var submitData = JSON.stringify(flatData);

            /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            var count = 0,
                content = ""; // 属性
            if (!file.isLoad) return true;
            if (!self.interactive.currentFinished) {
                self.ui.fade("当前图片尚未加载完毕");
                return false;
            }

            for (var i = 0; i < flatData.length; i++) {
                var itemReadOnly = self.readOnly.indexOf(flatData[i].type) > -1; // bcjia修改
                if (flatData[i].text.length > 1000) {
                    // 如果内容超过 1000个字
                    if (!isAuto) {
                        self.ui.fade("内容框文字不能超过1000字符");
                        self.setClick(flatData[i].id);
                        return false;
                    }
                }
                if (self.requiredLabel && flatData[i].region != "polyline" && !!!flatData[i].type) {
                    if (!isAuto) {
                        self.ui.fade("当前批次任务必须选择属性");
                        self.setClick(flatData[i].id);
                        return false;
                    }
                }
                if (self.isTranscription && !flatData[i].isFirst && !!!flatData[i].text && !itemReadOnly) {
                    // bcjia
                    if (!isAuto) {
                        self.ui.fade("当前批次任务必须进行转写");
                        self.setClick(flatData[i].id);
                        return false;
                    }
                }
                if (self.isPointLabel && (!!!flatData[i].startPoint || !!!flatData[i].endPoint)) {
                    if (!isAuto) {
                        self.ui.fade("当前批次任务必须进行标记点");
                        self.setClick(flatData[i].id);
                        return false;
                    }
                }
                count++;
            }

            if (!count && !self.files.current.isBad) {
                if (!isAuto) {
                    self.ui.fade("至少需要一个绘图框"); // 至少需要一个标记属性的绘图框
                }
                return false;
            }

            try {
                content = submitData;
            } catch (e) {
                content = "{}";
            }

            if (content === "{}") {
                return false;
            }
            return true;
        },
        /**
         * 保存方法
         * @param isAuto 是否自动
         * @param async 是否异步   改造后同步异步通过async await完成 不通过参数
         * @param success 成功回调
         * @param errorMethod 失败回调
         */
        saveResult: function(isAuto, success, errorMethod) {
            let file = self.getFile();
            let flatData = self.treeToFlatData(file.result);
            let submitData = JSON.stringify(flatData);

            // 校验结果数据
            if(!this.saveCheckData()) return false;
            // 判断数值是否有更改
            // 自动 判断文本变化，无论上次是手动还是自动保存
            // 手动 上次是自动，则不比较文本变化，如果上次是手动则比较变化
            // 文本是否有变化，有变化保存，没有变化判断是否是自动保存和手动保存下上次也是手动保存
            // 2018/8/20 增加了判断 只有当文件
            // if (self.Utils.isNotNull(file.lastSubmit) && self.Utils.isNotNull(file.lastSubmit.result) && file.lastSubmit.result == submitData && file.status == 1) {
            if (
                self.Utils.isNotNull(file.lastSubmit) &&
                self.Utils.isNotNull(file.lastSubmit.result) &&
                file.lastSubmit.result == submitData
            ) {
                if (isAuto || file.lastSubmit.isLastAuto === isAuto) {
                    // isAuto == true 或者 isAuto 和 lastIsAuto 都为false 表示上次也是手动存储的
                    // ui.fade("结果已保存"); //没有变化只给提示
                    file.lastSubmit.isLastAuto = isAuto;
                    //  if(!isAuto){ file.status = 1;} // 如果是手动保存，则更改保存状态
                    // success ? success() : "";
                    // isOk = true;
                    return Promise.resolve();
                }
            }

            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            var params = {
                lastIndex: file.id,
                result: {
                    markTaskFileId: file.id,
                    batchId: self.base.batchId,
                    markTaskId: self.markTaskId,
                    stamp: file.isBad,
                    isCheck: false,
                    resultText: submitData,
                    autoSave: isAuto
                }
            };

            file.saveSuccess = false; // 设置 保存状态
            self.interactive.saveSuccess = false; // 默认设置当前数据请求尚未保存成功
            // 先修改status代表已标注 测试
            return self.ass_api.saveResult({
                markTaskId: self.markTaskId,
                markFileId: file.id,
                recheck: self.recheck},params).then(data => { // 保存成功
                    if (!isAuto) {
                        file.status = 1;
                    } // 已标注
                    file.saveSuccess = true;
                    // file.status = 1;
                    file.lastSubmit = {
                        isLastAuto: isAuto,
                        result: submitData
                    }
                    return;
            }).catch( err => {
                file.saveSuccess = false; // 保存失败
                self.interactive.saveSuccess = true; // 数据请求成功
                // errorMethod ? errorMethod(err) : "";
                return Promise.reject(err)
            })
        },
        // 获取光标位置 快速插入
        textareaMouseUpFn: function(e) {
            // e.preventDefault()
            this.banDrop = false;
            this.$nextTick(function() {
                this.cursorLocation = e.target.selectionStart;
            });
        },
        textareaIpt: function(e) {
            this.$nextTick(function() {
                this.cursorLocation = e.target.selectionStart;
            });
        },
        // 编辑框 失去焦点
        textareaBlur: function(e, item) {
            this.textareaFocus = false;
            var item = item ? item : this.vm.currentDrawData;
            this.calculateModificationRate(item);
        },
        // 快速插入标签 bcjia 修改
        fastInsertFn: function(val, key, item) {
            var item = item ? item : this.vm.currentDrawData;
            if (this.readOnly.indexOf(item.type) === -1) {
                item.text = item.text.substring(0, this.cursorLocation) + key + item.text.substring(this.cursorLocation);
                this.cursorLocation += key.length;
            }
        },
        // 设置选择角度
        setImgRotate: function() {
            if (this.vm.rotateDeg === 4) {
                this.vm.rotateDeg = 1;
            } else {
                this.vm.rotateDeg++;
            }
            svg.setImageAngle(this.vm.rotateDeg);
        },
        // 标为坏数据或者好数据
        markBadData: function(e, hCheck) {
            if (this.history.showVersionInfo || this.history.show) {
                // 如果查看历史
                return false;
            }

            var file = self.getFile();

            if (hCheck) {
                file.isBad = 1; // 修改当前文件状态
                // self.destoryAllDraw(); // 删除数据 删除框
                // self.saveResult(false, true, function() {
                //     file.status = 1; // 代表当前已经标注
                //     // self.next(); // 标坏自动跳转下一条
                // }); // 并保存
                const savePromise = self.saveResult(false);
                savePromise && savePromise.then(() => {
                    file.status = 1; // 代表当前已经标注
                    // self.next(); // 标坏自动跳转下一条
                })
                return;
            }
            if (file.isBad == 0) {
                if (!self.operate.isKeydownPrepare) {
                    return false;
                }
                self.operate.isKeydownPrepare = false;
                self.ui.confirm("标记为坏数据后，已标注内容将被清除").then(() => {
                    // 删除当前元素
                    self.operate.isKeydownPrepare = true;
                    file.isBad = 1; // 修改当前文件状态
                    self.destoryAllDraw(); // 删除数据 删除框
                    // self.saveResult(false, true, function() {
                    //     file.status = 1; // 代表当前已经标注
                    //     self.next(); // 标坏自动跳转下一条
                    // }); // 并保存
                    const savePromise = self.saveResult(false);
                    savePromise && savePromise.then(() => {
                        file.status = 1; // 代表当前已经标注
                        self.next(); // 标坏自动跳转下一条
                    })

                }).catch(action => {
                    // action === 'cancel' 点击取消按钮
                    // action === 'close' 点击叉
                    self.operate.isKeydownPrepare = true;
                })
            } else {
                if (file.isLoad) {
                    file.isBad = 0;
                } else {
                    self.ui.fade("当前图片不可用，不可标为好数据");
                }
            }
        },
        // 销毁图标上的所有框
        destoryAllDraw: function() {
            // 清空数据
            this.files.current.result = [];
            this.vm.list = []; // 重新赋值了，不会改变其他引用的值
            this.vm.currentDrawData = {};
            var area_box_group = SVG.select(".area-box-group");
            var adjust_size = SVG.select(".adjust-size");
            area_box_group.each(function() {
                this.remove();
            });
            adjust_size.each(function(item) {
                this.remove();
            });
        },
        /**
         *  提交
         */
        async submitResult () {
            var len = self.files.allInfo.length;

            function skipUnSave(_p) {
                if (self.files.showType != 1) {
                    self.selectData(1);
                }
                self.skipFile(_p, true);
            }

            function prejudgeSubmit() {
                for (var i = 0; i < len; i++) {
                    var item = self.files.allInfo[i];
                    if (item.status == 0) {
                        self.ui.fade(item.name + " 未完成标注,请完成标注后提交");
                        skipUnSave(item);
                        return false;
                    }
                    if (!item.saveSuccess) {
                        self.ui.fade(item.name + " 保存失败，不能完成提交");
                        skipUnSave(item);
                        return false;
                    }
                }
                return true;
            }
            const savePromise = self.saveResult(false);
            if (self.base.step == 0) {
                savePromise && await savePromise.then(() => {
                        if (prejudgeSubmit()) {
                            // 标注提交
                            self.operate.isKeydownPrepare = false; // 2018/8/17 只有成功进入弹框
                            self.ui.confirm("任务已完成，确认提交？").then(()=>{
                                self.operate.isKeydownPrepare = true; // 2018/8/17 成功后 取消
                                self.ass_api.submitTask(self.markTaskId, "").then(() => {
                                    self.ui.fade("提交成功...");
                                    clearInterval(self.operate.autoSaveInterval);
                                    self.history.submitsuccess = true;
                                    // self.closeResult();
                                });
                            }).catch(action => {
                                self.operate.isKeydownPrepare = true; // 2018/8/17 成功后 取消
                            })
                        }
                }).catch( err => {
                    // ass_api.error(err, self.base.step);
                })
                // self.operate.isKeydownPrepare = true;
            } else if (self.base.step == 1) {
                // 检查提交
                savePromise && await savePromise.then(() => {
                    if (prejudgeSubmit()) {
                        self.operate.isKeydownPrepare = false; // 2018/8/17 只有成功进入弹框
                        // 检查提交弹窗
                        self.ui.check_confirm("操作", "评价:", undefined, "提交").then(() => {
                            self.ui.confirm("任务已完成，确认提交？").then(() => {
                                self.operate.isKeydownPrepare = true; // 2018/8/17 只有成功进入弹框
                                self.ass_api.submitTask(self.markTaskId,JSON.stringify({isQualified: 0,evaluate: content}))
                                    .then(() => {
                                        self.ui.fade("提交成功...");
                                        clearInterval(self.operate.autoSaveInterval);
                                        self.history.submitsuccess = true;
                                        // self.closeResult();
                                })
                            }).catch( action => {
                                self.operate.isKeydownPrepare = true; // 2018/8/17 只有成功进入弹框
                            })
                            return true;
                        }).catch( action => {
                            self.operate.isKeydownPrepare = true; // 2018/8/17 只有成功进入弹框
                            return true;
                        })
                        
                    }
                }).catch( err => {
                    // ass_api.error(err, self.base.step);
                })

            } else if (self.base.step == 2) {
                // 质检提交
                savePromise && await savePromise.then(() => {
                    if (prejudgeSubmit()) {
                        self.operate.isKeydownPrepare = false; // 2018/8/17 只有成功进入弹框
                        // 质检提交弹窗
                        self.ui.custom_comfirm().then(data => {
                            var content = data.evaluate.trim();
                            self.ui.confirm("任务已完成，确认提交？").then(() => {
                                self.operate.isKeydownPrepare = true; // 2018/8/17 只有成功进入弹框
                                self.ass_api.submitTask(self.markTaskId,JSON.stringify({isQualified: data.isQualified,evaluate: content}))
                                    .then(() => {
                                        self.ui.fade("提交成功...");
                                        clearInterval(self.operate.autoSaveInterval);
                                        self.closeResult();
                                })
                            }).catch( action => {
                                self.operate.isKeydownPrepare = true; // 2018/8/17 只有成功进入弹框
                            })
                            return true;
                        }).catch( action => {
                            self.operate.isKeydownPrepare = true; // 2018/8/17 只有成功进入弹框
                            return true;
                        })
                    }
                }).catch( err => {
                    // ass_api.error(err, self.base.step);
                })
            }
        },
        // 关闭
        closeResult: function() {
            this.Utils.closeResult(self.base.step);
        },
        /**
         * 由于公用的 fade 无法满足需求
         * @param t 提示内容
         */
        // addFade: function(t) {
        //     var html = $('<i class="fade_e">' + t + "</i>");
        //     $("body").append(html);
        //     html.css("margin-left", -(html.width() + 32) / 2);
        //     var hideOut = function() {
        //         html.animate({opacity: 0}, "normal",function() {
        //             html.remove();
        //         });
        //     };
        //     setTimeout(hideOut, 2000);
        // },
        // 查看历史结果
        async viewVersion(item) {
            this.checkboxsGroup.serial = false;
            this.checkboxsGroup.inHeritAttr = false;
            var fileId = self.getFile().id;
            self.history.show = false;
            self.history.showVersionInfo = true;
            self.vm.type = "click"; // 初始化 类型
            await this.ass_api.getHistoryInfo(self.taskId, self.markTaskId, fileId, item.version)
                .then(info => {
                    if(!info) return; // 
                    self.history.current = self.flatToTreeData(JSON.parse(info.resultText)); // 当前历史数据
                    self.history.beforeIsBad = self.files.current.isBad; // 保存之前的好坏数据
                    self.history.beforeHistoryData = self.treeToFlatData(self.files.current.result); // 切换历史前的数据 简单的深拷贝
                    self.destoryAllDraw(); // 销毁当前所有的图形和数据
                    svg.destroyEvents("mousemove"); // 销毁默认拖动事件
                    svg.bindEvents("mousemove", self.customDrag, 1); // 自定义拖动事件
                    // self.files.current.result = self.flatToTreeData(JSON.parse(item.resultText));
                    self.$set(self.files.current, "result", self.flatToTreeData(JSON.parse(info.resultText)));
                    self.files.current.isBad = info.extend.stamp; // 好坏数据赋值
            });
            self.dataConversion(self.files.current.result, true, true); // 重新绘图并赋值
        },
        // 自定义拖动事件 只有 拖拽有用
        customDrag: function(e) {
            if (this.vm.type === "drag" && svg.dm.drawStatus) {
                // 如果是拖动,切符合拖动条件
                svg.getPoint(e, 0); // 首先获取当前点
                svg.svgToMoveDrag(e); // 移动
            }
            svg.initWheelPoint(); // 初始化滚动参数
        },
        // 开发到此....................
        // 恢复历史结果 (是否传入参数)
        async recoverVersion (pInfo) {
            var result = null;
            var fileId = self.getFile().id;
            if (self.Utils.isNull(pInfo)) {
                // 暂时不做处理 因为已经处理过了
                svg.destroyEvents("mousemove"); // 销毁 之前自定义的事件
                svg.addBaseEvent("mousemove"); // 添加mousemove事件
            } else {
                // 直接绘图
                self.destoryAllDraw(); // 销毁当前所有的图形和数据
                await this.ass_api.getHistoryInfo(
                    self.taskId,
                    self.markTaskId,
                    fileId,
                pInfo.version).then((pInfo) => {
                    result = self.flatToTreeData(JSON.parse(pInfo.resultText));
                    self.$set(self.files.current, "result", result); // 赋值
                    self.files.current.isBad = pInfo.extend.stamp; // 好坏数据赋值
                });

                self.dataConversion(self.files.current.result, true, true); // 重新绘图并赋值
            }
            const savePromise = self.saveResult(true); // 异步自动 无回调逻辑
            self.history.show = false;
            self.history.showVersionInfo = false;
        },
        // 关闭历史结果
        closeVersion: function() {
            self.history.show = false;
            self.history.showVersionInfo = false;
            self.vm.type = "click"; // 初始化 类型
            self.history.current = {}; // 重新赋值 并不会影响到 原引用指向的值
            self.destoryAllDraw(); // 销毁当前所有的图形和数据
            svg.destroyEvents("mousemove"); // 销毁 之前自定义的事件
            svg.addBaseEvent("mousemove"); // 添加mousemove事件
            self.$set(self.files.current, "result", self.flatToTreeData(self.history.beforeHistoryData));
            self.files.current.isBad = self.history.beforeIsBad; // 恢复之前的好坏数据
            self.history.beforeHistoryData = {}; // 清空保存的数据
            self.dataConversion(self.files.current.result, true, true); // 重新绘图并赋值
            self.setClick("svgImage");
        },
        // 快速编辑
        quickEditFn: function() {
            var id = this.vm.selectId;
            if (!id) return;
            var list = this.showList,
                ind = -1;
            for (var i = 0; i < list.length; i++) {
                if (list[i].id == id) {
                    this.selAttrFn("", i, list[i]);
                    ind = i;
                    break;
                }
            }
            if (ind != -1) {
                this.$nextTick(function() {
                    setTimeout(function() {
                        $(self.$refs[list[ind].id][0]).focus();
                    });
                });
            }
        },
        // 打回
        async repulse() {
            // 检查环节的打回操作
            const savePromise = self.saveResult(false); 
            savePromise && await savePromise.then(()=>{
                self.operate.isKeydownPrepare = true;
                self.ui.check_confirm('打回操作', '打回操作',undefined, '提交').then(val => {
                    var content = val.value;
                    if (self.base.step === 1) {
                        // 主平台复检
                        self.ass_api.submitTask(self.markTaskId,JSON.stringify({isQualified: 1, evaluate: content}))
                            .then(() => {
                                self.ui.successGoBase("打回成功...");
                                self.closeResult(self.base.step);
                        });
                    } else if (self.base.step === 2) {
                        // 主平台复检
                        self.ass_api.repulseTask(self.markTaskId,JSON.stringify({isQualified: 1,evaluate: content}))
                            .then(()=> {
                                self.ui.successGoBase("打回成功...");
                                self.closeResult();
                        });
                    }
                    self.operate.isKeydownPrepare = true;
                    return true;
                }).catch(action => {
                    self.operate.isKeydownPrepare = true;
                    return true;
                })
            }).catch(err => console.log(err)) // 注意await的promise回调，一定要加上catch
        },
        // 控制点的回调
        pointCallBack: function(id) {
            // 点id
            var curData = this.vm.currentDrawData;

            if (curData.region == "rect" && this.ctrlDown) {
                // ctrl + 矩形
                var cx = SVG.get(id).cx(),
                    cy = SVG.get(id).cy();
                this.rectanglePolygon(curData.id, cx, cy);
            }
        },
        sxFn: function() {
            if (!this.history.showVersionInfo)
                return (this.filterBoxShow = true);
        },
        // 全局关闭选择标签框和列表合并
        globalCloseUnfold: function() {
            this.lebalLebals = false;
            this.preListsObj ? (this.preListsObj.unfold = false) : "";
        },
        // 关闭弹窗
        closeSignPopup: function() {
            this.pointPopupShow = false;
            this.poppupShow = false;
        },
        cententLeftFn: function() {
            this.globalCloseUnfold();
            if (!this.textareaFocus) {
                this.poppupShow = false;
                this.pointPopupShow = false;
            }
        },
        // 调用整体转换的接口
        getOverallConversion: function(zxType) {
            if (this.roboting) {
                // 判断是否正在转写
                self.ui.fade("正在转写中，请勿多次请求");
                return false;
            }

            var file = self.getFile(), // 当前文件内容
                url = file.url,
                params, // url
                host = "http://" + window.location.host, // 'http://' + window.location.host ,        // 'http://172.31.202.69' ,
                postUrl =
                    zxType === "jieda"
                        ? "/engine/ImgOCR/3_0/app"
                        : zxType === "susuan"
                            ? "/engine/ImgOCR/3_0/mpc"
                            : zxType === "tiankong"
                                ? "/engine/ImgOCR/3_0/blank "
                                : zxType === "zrcj"
                                    ? "/engine/ImgOCR/3_0/natural-scene"
                                    : zxType === "fuzhu"
                                        ? "/engine/ImgOCR/3_0/edu-assist"
                                        : ""; // 转写api
            var flatData = self.treeToFlatData(file.result);
            // 多边形提交 点的格式字符串转成数组
            flatData.forEach(function(item) {
                if (item.region == "area") {
                    item.points = self.polygonToNeed(item.points);
                } else if (item.region == "polyline") {
                    if (
                        typeof item.points != "object" &&
                        typeof item.points == "string"
                    ) {
                        // 折线point格式 保存时 再过滤一遍 确保保存的是[ [0,0] , [1,2] ]数组的格式
                        item.points = self.polygonToNeed(item.points);
                    }
                }
            });
            var record = JSON.stringify(flatData); // 标记框信息
            try {
                // 判断绘图框是否为空
                if (record == "[]") {
                    self.ui.fade("未检测到绘图框");
                    return false;
                }
            } catch (e) {
                self.ui.fade("未检测到绘图框");
                return false;
            }
            params = {
                url: host + url,
                resultText: record
            };

            params = JSON.stringify(params);

            this.postRequest(
                postUrl,
                params,
                "post",
                true,
                function(data) {
                    var resultText;
                    data = JSON.parse(data);

                    if (data.status == 500) {
                        // 500 状态
                        self.ui.error("转写失败");
                        return;
                    }

                    try {
                        resultText = JSON.parse(data.data);
                    } catch (e) {
                        console.warn("转写数据，和预期不相同，需要排查");
                        resultText = [];
                    }
                    self.overallConversion(JSON.parse(data.data));
                },
                function() {
                    self.ui.error("转写失败");
                }
            );
        },
        postRequest: function(url, params, method, async, success, error) {
            var form = new FormData();
            var xmlhttp;

            form.append("data", params);

            if (window.XMLHttpRequest) {
                xmlhttp = new XMLHttpRequest();
            } else {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }

            this.roboting = true; // 正在转写中

            if ($("body #loading").length == 0) {
                $("body").append(
                    '<div id="loading"><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div></div>'
                );
            }

            xmlhttp.timeout = 30000; // 请求超时的时间
            xmlhttp.ontimeout = function(e) {
                // 请求超时
                self.ui.error("请求超时,转写失败");
                $("body #loading").remove();
                self.roboting = false;
            };
            xmlhttp.onerror = function(e) {
                // 请求失败
                self.ui.error("请求错误,转写失败");
                $("body #loading").remove();
                self.roboting = false;
            };
            xmlhttp.onreadystatechange = function() {
                // 请求中
                if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                    $("body #loading").remove();
                    self.roboting = false;
                    success(xmlhttp.responseText);
                } else if (xmlhttp.readyState == 4 && xmlhttp.status == 500) {
                    $("body #loading").remove();
                    self.roboting = false;
                    error();
                }
            };
            xmlhttp.open("POST", url, true);
            xmlhttp.send(form);
        },
        // 整体语义转换 (具体情况看返回数据)
        overallConversion: function(data) {
            if (typeof data !== "object") {
                console.warn("数据格式不符合规范");
                return false;
            }

            for (var i = 0, len = data.length; i < len; i++) {
                var id = data[i].id,
                    lists = this.showList;
                for (var j = 0; j < lists.length; j++) {
                    var readOnly = self.readOnly.indexOf(lists[j].type) > -1; // bcjia修改
                    if (lists[j].id === id) {
                        if (!!!lists[j].text && !readOnly) {
                            // 无转写文本时  才进行引擎转写
                            self.$set(lists[j], "text", data[i].text);
                            self.$set(lists[j], "machineTxt", data[i].text); // 赋值machineTxt
                        }
                        break;
                    }
                }
            }
            // 执行计算修改率
            this.calculateModificationRate(this.showList);
        },
        popupDrag: function(ev) {
            var ev = ev || event;
            var obj = document.getElementById("self_popup_wrapper");
            var disX = ev.clientX - obj.offsetLeft;
            var disY = ev.clientY - obj.offsetTop;

            if (obj.setCapture) {
                obj.setCapture();
            }
            document.onmousemove = function(ev) {
                var ev = ev || event;
                $(obj).css({
                    left: ev.clientX - disX + "px",
                    top: ev.clientY - disY + "px",
                    right: "auto",
                    bottom: "auto"
                });
            };

            document.onmouseup = function() {
                document.onmousemove = document.onmouseup = null;
                //释放全局捕获 releaseCapture();
                if (obj.releaseCapture) {
                    obj.releaseCapture();
                }
            };

            return false;
        },
        // 复检新增
        GetQueryString: function(name) {
            //流转任务时获取batchid
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        },
        executNow() {
            var self = this;
            self.postData.currPage = 1;
            self.postData.pageSize = self.pageSize;
            //查询结果获取
            var loadList = function(data) {
                if (data.list == undefined || data.list == null || data.list == "") return;
                if (data.count == self.MytaskList) {
                    self.ui.fade("任务下发中,请稍后点击！");
                } else {
                    data.list.sort(function(a, b) {
                        return b.createTime * 1 - a.createTime * 1;
                    });
                    var markTaskId = data.list[0].markTaskId;
                    var url =
                        "/assets/home/mark-page/?taskId=" +
                        this.taskId +
                        "&markTaskId=" +
                        markTaskId;
                    window.open(url);
                    self.closeResult();
                }
            };
            this.ass_api.pageNav(self.postData).then(loadList)
        },
        getMytaskList() {
            var self = this;
            self.postData.currPage = 1;
            self.postData.pageSize = self.pageSize;
            //查询结果获取
            var loadList = function(data) {
                if (data.list == undefined || data.list == null || data.list == "") return;
                self.MytaskList = data.count;
            };
            this.ass_api.pageNav(self.postData).then(loadList);
        },
        doApply: function(taskId, step, count) {
            var self = this;
            var url =
                "/v1/be/task/apply?taskId=" +
                this.taskId +
                "&step=" +
                step +
                "&sync=true";
            if (step == 0) {
                // 标注
                var params = {};
                var data = [];
                var item = {};
                item.count = parseInt(count);
                // 此参数不可删除
                item.userid = "";
                data.push(item);
                params.data = data;
                params.hasCount = true;
                LoadAjax.method(
                    url,
                    JSON.stringify(params),
                    "POST",
                    function(data) {
                        if (data == undefined || data == "") {
                            return;
                        }
                        //if (data.rt.status == 200) {
                        if (
                            data.rt.status == 200 &&
                            eval("(" + data.data + ")")[0].count > 0
                        ) {
                            self.history.getSuccess = true;
                            return;
                        } else {
                            if (data.rt.status == 400004) {
                                self.ui.error(lang.member_list_view_msg14);
                                return;
                            } else if (data.rt.status == 400005) {
                                self.ui.error(lang.member_list_view_msg15);
                                return;
                            }
                            self.ui.error(lang.member_list_view_msg16);
                        }
                    },
                    false
                );
            } else if (step == 1) {
                // 检查
                var params = {};
                var data = [];
                var item = {};
                // 此参数不可删除
                item.userid = "";
                data.push(item);
                params.data = data;
                params.hasCount = true;
                LoadAjax.method(
                    url,
                    JSON.stringify(params),
                    "POST",
                    function(data) {
                        if (data == null || data == "") {
                            return;
                        }
                        if (
                            data.rt.status == 200 &&
                            eval("(" + data.data + ")")[0].count > 0
                        ) {
                            self.history.getSuccess = true;
                            return;
                        } else {
                            if (data.rt.status == 400004) {
                                self.ui.error(lang.member_list_view_msg14);
                                return;
                            } else if (data.rt.status == 400005) {
                                self.ui.error(lang.member_list_view_msg15);
                                return;
                            }
                            self.ui.error(lang.member_list_view_msg16);
                        }
                    },
                    false
                );
            } else {
                self.ui.error(lang.member_list_view_msg17);
            }
        },
        // 加入团队
        joinTeam: function(teamId) {
            var url = "/v1/marker-recruit/team/apply";
            LoadAjax.method(url, { team_id: teamId }, "POST", function(data) {
                if (data == null || data == "") {
                    return;
                }
                if (data.rt.status == 200) {
                    self.ui.successGoBase(lang.member_list_view_msg18);
                } else if (data.rt.status == 100005) {
                    self.ui.fade(lang.member_list_view_msg18);
                } else if (data.rt.status == 100002) {
                    self.MessageBox.alert(lang.member_list_view_msg19, '操作提醒');
                } else {
                    self.ui.error(data.data);
                }
            });
        },
        // 是否可以参加任务
        canJoinTask: function(taskid, markstatus, step) {
            var self = this;
            //关闭弹窗
            self.closePop();
            // 是否是团队开放任务   1.完全开放2.勋章开放3.团队开放4.勋章和团队开放
            var authType = "";
            if (markstatus == 2) {
                authType = "medal";
            } else if (markstatus == 3) {
                authType = "team";
            } else if (markstatus == 4) {
                authType = "medal_team";
            } else if (markstatus == 1) {
                authType = "public";
            }
            // 检查用户是否有权限参加任务
            LoadAjax.method(
                "/v1/task/can-join",
                { taskId: taskid, authType: authType, step: step },
                "GET",
                function(data) {
                    var res = data;
                    if (res == null || res == "") {
                        self.ui.error(lang.member_list_view_msg2);
                        return;
                    }
                    if (res.rt.status != 200) {
                        self.ui.error(result.data);
                        return;
                    }
                    if (res.data == null || res.data == "") {
                        self.ui.error(lang.member_list_view_msg2);
                        return;
                    }
                    if (res.rt.status == 200) {
                        if (step == 0) {
                            if (res.data.code == 2) {
                                if (
                                    res.data.team != null &&
                                    res.data.team != ""
                                ) {
                                    ui.confirm(
                                        lang.member_list_view_msg3,
                                        function() {
                                            self.joinTeam(res.data.team);
                                        }
                                    );
                                } else if (res.data.medal != null && res.data.medal != "") {
                                    ui.confirm(
                                        lang.member_list_view_msg4,
                                        function() {
                                            window.open(
                                                "/assets/home/medal-page/?medal_id=" +
                                                    res.data.medal
                                            );
                                        }
                                    );
                                } else {
                                     self.ui.fade(lang.member_list_view_msg5);
                                }
                                return;
                            }
                            if (res.data.code == 3) {
                                self.ui.error(lang.member_list_view_msg6);
                                return;
                            }
                            if (res.data.code == 4) {
                                ui.message(lang.member_list_view_msg7);
                                return;
                            }
                            if (res.data.code == 1) {
                                self.doApply(taskid, step, self.countVal);
                            }
                        } else if (step == 1) {
                            // 检查
                            if (res.data.code == 2) {
                                ui.message(lang.member_list_view_msg8);
                                return;
                            }
                            if (res.data.code == 3) {
                                self.ui.error(lang.member_list_view_msg9);
                                return;
                            }
                            if (res.data.code == 4) {
                                ui.message(lang.member_list_view_msg7);
                                return;
                            }
                            if (res.data.code == 1) {
                                self.doApply(taskid, step, null);
                            }
                        }
                    }
                }
            );
        },
        apply: function() {
            var self = this;
            if (self.apply_type == "custom" && self.task_type == "mark") {
                // 自定义数量申请
                if (self.countVal == null || self.countVal == "") {
                    if (!$("input[name='lab_val']").hasClass("err")) {
                        $("input[name='lab_val']")
                            .removeClass("yes")
                            .addClass("err")
                            .after(
                                "<div class='error'>" +
                                    lang.member_list_view_msg10 +
                                    "</div>"
                            );
                    }
                    return;
                }
                if (
                    this.countVal < this.single_min ||
                    this.countVal > this.single_max
                ) {
                    this.countVal = this.single_min;
                    if (!$("input[name='lab_val']").hasClass("err")) {
                        $("input[name='lab_val']")
                            .removeClass("yes")
                            .addClass("err")
                            .after(
                                '<div class="error"><var>' +
                                    lang.member_list_view_msg11 +
                                    "</var>" +
                                    this.single_min +
                                    " - " +
                                    this.single_max +
                                    "<var>" +
                                    lang.member_list_view_msg12 +
                                    "</var></div>"
                            );
                    }
                    return;
                }
            }
            var step = this.task_type == "mark" ? 0 : 1;
            this.canJoinTask(this.taskId, this.markstatus, step);
        },
        closePop: function() {
            this.history.hidePop = false;
        },
        // 加入任务
        joinTask: function() {
            var self = this;
            this.history.hidePop = true;
            this.getMytaskList();
            var proxyurl = "/v1/task/detail?taskId=";
            LoadAjax.method(proxyurl + this.taskId, "", "GET", function(data) {
                if (data.rt.status == 200) {
                    self.task = data.data;
                    self.history.submitsuccess = false;
                    // 检查用户是否有权限申请任务
                    self.apply_type =
                        self.task.countlevel == undefined ||
                        self.task.countlevel == ""
                            ? "custom"
                            : "gradient";
                    if (self.apply_type == "gradient") {
                        self.count_level = self.task.countlevel.split(";");
                        // 排序
                        self.count_level = self.count_level.sort(function(
                            a,
                            b
                        ) {
                            return a - b;
                        });
                        self.countVal = self.count_level[0];
                    }
                    self.single_min = self.task.singlemin;
                    self.single_max = self.task.singlemax;
                } else {
                    self.ui.error(lang.member_list_view_msg1);
                }
            });
        },
        changeTab: function(index) {
            this.task_type = index;
        }
    },
    filters: {
        formatTime: function(val) {
            // return parseFloat(val + '').toFixed(2)
            if (!!!val) return "00:00";
            var zNum = val < 1 ? Math.ceil(val) : parseInt(val);
            return (
                parseInt(zNum / 60) +
                ":" +
                (parseInt(zNum % 60) < 10
                    ? "0" + parseInt(zNum % 60)
                    : parseInt(zNum % 60))
            );
        },
        toDateTime: function(_value) {
            // 时间转换器
            if (_value == undefined) return "--";
            return self.Utils.toDateTime(_value);
        },
        takeTwoDecimal: function(val) {
            var type = typeof val;
            if (type !== "number") {
                return "100%";
            }
            return Math.ceil((val * 100).toFixed(2)) + "%";
        },
        attrTitle: function(item) {
            if (!self.checkType) return "";
            return !!item.type
                ? self.checkType[item.type]
                : item.unfold ? "" : item.text;
        }
    }
};
// 保留八位比较
function KeepEight(num){
    return parseInt(num * 100000000) / 100000000
}
</script>
     
<style>
@import "../assets/css/jingxihua/index.css";
</style>
